mercredi 3 novembre 2021

Wrong if statement valuation? [closed]

Why does python still enter the if loop even though it doesn't meet the requirement?

user_input = "x".strip()

if user_input != 'l' and user_input != 'a' and user_input != 'd' and user_input != 'c' and user_input != 'e' and user_input != 's' and user_input != 'x':
    sys.stdout.write("Incorrect choice!\n")
    user_input = "invalid"

P.S. I've tried with both '' and "".

Aucun commentaire:

Enregistrer un commentaire