Ask Question
1 March, 17:42

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.

+2
Answers (1)
  1. 1 March, 20:07
    0
    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 / n")) #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!

    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.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “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, ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers