I'm new to Python and have written a program that determines if a letter in a string entered is a vowel or consonant. If the letter is a vowel the program prints 'vowel' but if a consonant it prints the consonant.
I've written the program in two different ways and cannot figure out why the second code set doesn't work. When run it returns 'vowel' for all letters in the string entered.
#this code works
word = input("Please enter a word: ")
for letter in word.lower():
if letter == 'a':
print("vowel")
elif letter == 'e':
print("vowel")
elif letter == 'i':
print("vowel")
elif letter == 'o':
print("vowel")
elif letter == 'u':
print("vowel")
else:
print(letter)
#this code doesn't work
word = input("Please enter a word: ")
for letter in word.lower():
if letter == 'a' or 'e' or 'i' or 'o' or 'u':
print("vowel")
else:
print(letter)
If I input 'David' in first code set it returns [d, vowel, v, vowel, d]. I'm wondering why the logic in the 'for' statement of the second set of code doesn't work. Why can I not use the comparison operator 'or' the way I have it in the second code sample? When the second set of code is run I get is the word 'vowel' returned for all letters in the string