vendredi 1 avril 2016

detecting vowels in python

I tried looking for a already answered question similar to this but my problem seems to be different. basically the user enters a letter and if its a vowel it should display a congratulatory message otherwise a "you lose" message

    letter = str(input('enter any letter '))
    if letter == ('a'or 'e'or 'i'or 'o' or'u'):
         print('congratulations you won')
    else: print('sorry you lose , better luck next time')

for some reason it only displays congratulatory message when I enter 'a' and will not work if i enter any of the other vowels, also I would like to know if there is any other way to simplify this without having to write an "or" between every option for future reference. thanks

Aucun commentaire:

Enregistrer un commentaire