Ask 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, e, i, o, or u), but otherwise writes out a "You lose, better luck next time" message.

+3
Answers (1)
  1. 1 June, 07:57
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers