Find the best answers to your questions at Westonci.ca, where experts and enthusiasts provide accurate, reliable information. Discover comprehensive solutions to your questions from a wide network of experts on our user-friendly platform. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.

Write a program that uses the function strcmp() to compare two strings input by the user. The program should state whether the first string is less than, equal to, or greater than the second string7. Write a program that uses the function strcmp() to compare two strings input by the user. The program should state whether the first string is less than, equal to, or greater than the second string

Sagot :

user_str1 = str ( input ("Please enter a phrase: "))

user_str2 = str ( input("Please enter a second phrase: "))

def strcmp (word):

user_in1 = int (len(user_str1))

user_in2 = int (len(user_str2))

if user_in1 > user_in2:

return "Your first phrase is longer"

elif user_in1 < user_in2:

return "Your second phrase is longer"

else:

return "Your phrases are of equal length"