With the code below, no matter what the first letter of the input is, it is always determined as a vowel:
original = raw_input("Please type in a word: ")
firstLetter = original[0]
print firstLetter
if firstLetter == "a" or "e" or "i" or "o" or "u":
print "vowel"
else:
print "consonant"
In fact, it doesn’t matter what the boolean is in the if statement… if it is == or != , it is still return "vowel". Why?
Python is not the English language. If you have a bunch of expressions with
ororandbetween them, each one must make sense on its own. Note that on its own:will always print
something, even ifletterdoesn’t equal"e".You need to do it like this:
Or, more concisely: