How to compare a user input against multiple OR conditions PYTHON 3.x

All you need to do is use a list [] square brackets, instead of curly ones (those are for sets) and you need to move the choice variable ahead. ( You want to see that the choice is in the list, and not the other way around. )

Your code should be :

choice = input("> ")

if choice in ['up', 'down', 'left', 'right']:
    print("You wrote a direction!")
else:
    print("Oh bummer.")

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top