Mat Whiteside
Mat Whiteside

Reputation: 561

"if variable not in list" not working returning true all the time

Why is this line of code always returning true?

def GetPlayersMove(self):
    self.move = input("Enter Rock, Paper or Scissors: ")
    if self.move.lower() not in ["rock" "paper", "scissors"]:
        print("Error")

Upvotes: 2

Views: 98

Answers (1)

falsetru
falsetru

Reputation: 369034

The code is missing ,.

["rock" "paper", "scissors"]
#      ^

"rock" "paper" is equivalent to "rockpaper":

>>> ["rock" "paper", "scissors"]
['rockpaper', 'scissors']
>>>

See String literal concatenation

Upvotes: 12

Related Questions