I am currently solving some simple python exercises i found online as a preparation for an exam I have next week. However, I keep having the same problem:
In an if statement, how can I test for multiple conditions ('or's)? (see below)
Example: when trying to check if a character is a vowel (and returning True if it is), i'd like to test for all five vowels, but if i write it like this, the first letter will be True (i.e. a), but e, i, o or u returns False, and I can't figure out why:
def vowel_or_not(char):
if char == ('a' or 'e' or 'i' or 'o' or 'u'):
return True
else:
return False
print(vowel_or_not('a')) # returns True
print(vowel_or_not('e')) # returns False
print(vowel_or_not('k')) # returns False
Any help would be greatly appreciated.