The reason it isn't working is because the condition in the if:
statement is incorrect. When you write
if first == "a" or "e" or "i" or "o" or "u":
... what it is really saying is
if (first == "a") or ("e") or ("i") or ("o") or ("u"):
That is to say, it only compares the value of first
to "a"
; the rest of the clauses all evaluate to True
, so the the whole condition will always be True
.
In order to compare a single value against several values, you need to use a list and a set membership (in
or not in
) operator:
if first in ["a", "e", "i", "o", "u"]:
Note that you also aren't handling the case of uppercase values, but that's a complication you can handle on your own, I think.