Try using the in
keyword:
if first in letter:
On your current code, you are comparing a string character (first
which equals the first character in word
) to a list. So, let's say my input is "a word"
. What your code is actually doing is:
if "a" == ["a", "b", "c"]:
which will always be false.
Using the in
keyword however is doing:
if "a" in ["a", "b", "c"]:
which tests whether "a"
is a member of ["a", "b", "c"]
and returns true in this case.