0

How are the two statements different?

if not (answer == "rock" or answer == "paper" or answer == "scissors"):
   quit()
if useranswer == "rock":
   somethingsomething()
if useranswer != "rock" or useranswer != "paper" or useranswer != "scissors":
   quit()
if useranswer == "rock":
   somethingsomething()

If I use the second implementation program quits no matter what input I use, but if I use first implementation it works normally.

Haymend
  • 19
  • 3

2 Answers2

1

There are three conditions in your statement (let them be A,B,C).
The first statement is not (A or B or C), which is equal to not(A) and not(B) and not(C).
The second statement is not (A) or not (B) or not (C). Since both statements evaluate differently, their outcome is different.

Abhinav Mathur
  • 7,791
  • 3
  • 10
  • 24
0

Change or to and because or works if either or both or all is true. And and works if all are true. So use and instead of or.

Wasif
  • 14,755
  • 3
  • 14
  • 34