Try using the in keyword:
if first in letter:
In the current code, you are comparing a string character ( first , which is equal to the first character in word ) in the list. So let my input be "a word" . Actually your code:
if "a" == ["a", "b", "c"]:
which will always be false.
Using the in keyword does:
if "a" in ["a", "b", "c"]:
which checks if "a" member of ["a", "b", "c"] and returns true in this case.
source share