Reputation: 93
my task is to Write a script that asks the user a question with a fixed number of possible answers. Heres what I have so far:
print("who's your favorite actor: Tom Cruise, Nicholas Cage, or Jonah Hill?")
user_input = input()
user_input = user_input.lower()
while user_input != "tom cruise" or "nicholas cage" or "jonah hill":
print("No seriously, who's your favorite actor?: Tom Cruise, Nicholas Cage, or Jonah Hill")
user_input = input()
if user_input == "tom cruise" or "nicholas cage" or "jonah hill":
print("...Thats your favorite actor...")
Everytime I run I get stuck in the while loop and keep getting asked "No seriously, who's your favorite actor?: Tom Cruise, Nicholas Cage, or Jonah Hill" I used the user_input.lower() because the input has to be case INsensitve. Any help would be VERY much appreciated!
Upvotes: 0
Views: 58
Reputation: 8422
You can't use Python syntax in that way. What you can do is test for membership in the set of the three actor names:
while user_input not in ["tom cruise", "nicholas cage", "jonah hill"]:
And then, for the equality test:
if user_input in ["tom cruise", "nicholas cage", "jonah hill"]:
Upvotes: 3