228k views
4 votes
1. If the words entered are in increasing alphabetical order, that is the 1st one comes before the 2nd one and the 2nd comes before the 3rd word alphabetically display the message: In alphabetical order

2 Answers

6 votes

Here's a simple Python program that checks if three words are in alphabetical order and displays the message "In alphabetical order" if they are:

word1 = input("Enter the first word: ")

word2 = input("Enter the second word: ")

word3 = input("Enter the third word: ")

if word1 < word2 and word2 < word3:

print("In alphabetical order")

else:

print("Not in alphabetical order")

In this program, the input function is used to prompt the user to enter three words. The program then checks if word1 comes before word2 and word2 comes before word3 alphabetically using the comparison operators <. If both conditions are true, the program prints "In alphabetical order". If not, it prints "Not in alphabetical order".

User Jgiles
by
7.7k points
3 votes
If the words entered are in increasing alphabetical order, the message "In alphabetical order" will be displayed.
User Akash Malhotra
by
7.9k points