Can someone tell me why my code is not working? with an explanation please

Question:


Repl link:

code snippet
```print("-- πŸ‘Šβœ‹βœŒ - Lets Play ROCK PAPER AND SCISSORS BABY - ✌ βœ‹πŸ‘Š --")
print()
p1 = input("Player1 name? ")
p2 = input("Player2 name? ")
r = ("R","R","ROCK","rock","Rock","r")
s = ("S","s","Scissor","scissor","SCISSOR","s")
p = ("P","p","Paper","paper","PAPER","p")
print("!Select your moves!")
p1move = input("Player 1 move>")
p2move = input("Player 2 move>")

if p1move == r and p2move == r :
  print(p2 ,"Its a draw ")
  
elif p1move == r and p2move == p :
  print(p2,"Wins")

elif p1move == r and p2move == s  :
  print(p1,"Wins")

elif p1move == p and p2move == r :
  print(p1,"Wins")
  
elif p1move == p and p2move == p :
  print("Its a Draw")
  
elif p1move == p and p2move == s :
  print(p2,"Wins")
  
elif p1move == s and p2move == r :
  print(p2,"Wins")

elif p1move == s and p2move == p :
  print(p1,"Wins")
else:
  if p1move == s and p2move == s :
    print("Its A draw again!")

Hi @AazarRasheed, You’re setting the variables r, s, p to what are called Tuples. They’re kind of like static lists.

Where you’re checking the moves through something like p1move == r you’re checking if the string input equals the tuple. This will never be true as they’re fundamentally different data types.

What you need to do instead is change all your == to in.
For example:

if p1move in r and p2move in r:
  print("It's a draw")

This checks whether your string is in the tuple, rather than the string exactly matching the tuple.

6 Likes