43.3k views
4 votes
Write a Python program that gets a single character from the user and writes out a congratulatory message if the character is a vowel (a, e, i, o, or u), but otherwise writes out a "You lose, better luck next time" message.

1 Answer

0 votes

Answer:

def vowel(a): #function to detect whether the character is vowel or not.

vow=['a','e','i','o','u'] #list of vowels.

if a in vow:

return True

else:

return False

character=str(input("Enter the character \\")) #taking input.

if vowel(character.lower()):#checking the character is vowel using the function vowel..

print("Congratulations!!!!") #congratulating.

else:

print("You lose better luck next time")#message.

Output:-

Enter the character

a

Congratulations!!!!

Step-by-step explanation:

I have created a function to check whether the given character is a vowel or not.

After that taking input from the user.

And checking that it is vowel or not.If it is vowel then printing the message.

User Hridayesh
by
6.7k points