Mar-24-2021, 11:55 PM
(Mar-19-2021, 11:14 AM)GOTO10 Wrote:(Mar-19-2021, 10:58 AM)ashergreen Wrote: It works! But I have one question: When I programmed in C many years ago, the "user1 != "rock"...." line worked perfectly and also worked when I played with BASIC back in the day. Why doesn't it work with Python?
You have an issue with your logic, not your Python code. This line will always evaluate to True, unlessuser1
is somehow simultaneously equal to all three values at once (not possible):
user1 != "rock" or user1 != "paper" or user1 != "scissors"You could useand
instead ofor
to fix this, or you could usein
to evaluate the variable against a group of options (a tuple in this case):
user1 not in ("rock", "paper", "scissors")
I tried the OR instead of AND and it didn't work. It appears that doing the list/tuple thing seems to be the only way to get it to work.