Question: Write a script that takes a character (i.e. a string of length 1) as input from the user and returns False if it is a
- Write a script that takes a character (i.e. a string of length 1) as input from the user and returns False if it is a consonant, True otherwise. A check on the length of the input string and its being alphabetical is required and if not, send a message to the user and ask again.
while True:
#prompts and receives user input
char = input('Please enter an alphabetical character:')
if char.isdigit(): #checks if input is numerical
print ('Invalid input.')
else:
if len(char) > 1: #checks if input is more than one character
print ('Invalid input.')
else:
if char == 'a' or 'e' or 'i' or 'o' or 'u' or 'y': #checks if input is a vowel
print ('True')
else:
print ('False')
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
