samedi 11 mai 2019

how to execute third elif condition?

im building a hangman game and want to check for "legal characters", if the player entered more then one sign, it should print "E1", if he entered something other then a-z print "E2" and if he entered more then one sign and not an a-z letter print "E3" i cant get to "E3", why is this happening and what am i doing wrong ?

import string
player_input = input("Guess a letter: ").lower()
aToz = string.ascii_lowercase[0:26]


if len(player_input) != 1:
print("E1")
elif player_input not in aToz:
    print("E2")
elif player_input not in aToz and len(player_input) != 1:
    print("E3")
else:
    print(player_input)

expected result is to get "E3" when typing more then one letter and some other sign. actual result is "E1"

Aucun commentaire:

Enregistrer un commentaire