Question
PYTHON QUESTION Write a program that reads in a word entered by the user and checks whether: the word has at least 8 characters, starts
PYTHON QUESTION
Write a program that reads in a word entered by the user and checks whether:
-
the word has at least 8 characters,
-
starts with a vowel,
-
has alternating vowels and consonants, and
-
the consonants are in increasing alphabetical order. Note that you can check letters for alphabetical order using <. For example:
>>> a < b True >>> z < b False
Your program should work for words entered the upper or lower case, and must use a single functionis_alternating(word) that returns True if the word has the above pattern and False otherwise. Hint: Remember to write a loop that goes through each letter and check for the necessary conditions. Using indexing is important here as you need to compare letters in different positions.
Here is an example run of this program:
Enter a word => eLimiNate eLimiNate The word 'eliminate' is alternating
Enter a word => ageneses ageneses The word 'ageneses' is not alternating
Enter a word => ADAGE ADAGE The word 'adage' is not alternating
The word eliminate has this alternating pattern since we have that: 'l' < 'm' < 'n' < 't'.
The word adage is not long enough, ageneses has two consonants that are identical and as a result not in strictly increasing alphabetical ordering.
Here is another hint that will help: Given a letter stored in the variable x, the boolean expression:
x in 'aeiou'
is True if and only if x is a lowercase vowel.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started