Ask Question

3. Write a program that has the user enter two Strings. Display whether the first String is less than (comes first alphabetically), equal to, or greater than (comes after alphabetically) the first.

+5
Answers (1)
  1. 17 July, 10:56
    0
    The solution code is written in Python 3

    firstStr = input ("Enter first string: ") secondStr = input ("Enter second string: ") if (firstStr secondStr) : print ("The second string comes first alphabetically.") else: print ("The first and second string are same")

    Explanation:

    Firstly, prompt the user to input two strings (Line 1 - 2).

    Next create if else if statement to check if the firstStr is less than, greater than or equal to the secondStr and then print the appropriate message accordingly (Line 4 - 9). For example, the program display message "The first string comes first alphabetically." if it find the firstStr is less than secondStr.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “3. Write a program that has the user enter two Strings. Display whether the first String is less than (comes first alphabetically), equal ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers