Reputation: 21
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
Upvotes: 0
Views: 380
Reputation: 532
The ('a' or 'e' ...)
line always evaluates to 'a', and that is what the letter
variable is being compared to.
Try:
if letter in 'aeiou':
...
Upvotes: 8