Day 014 - Project 14 : 2 player rock paper scissors

Thank you lol. Now we shall never speak about this again haha.

The answer the user puts is invisible and it doesnt print the right text

print("Rock Paper Scissors  ")
print("R, P, or S")

from getpass import getpass as input

one = input("Player 1 > ")
two = input("Player 2 > ")

if one == "R" or "r" and two == "P" or "p":
  print("Player 2's paper smothers Player 1's rock!")
elif one == "R" or "r" and two == "S" or "s":
  print("Player 1's rock smashes Player 2's scissors!")
elif one == "R" or "r" and two == "R" or "r":
  print("Draw, no one wins!")
elif one == "S" or "s" and two == "S" or "s" :
  print("Draw, no one wins!")
elif one == "P" or "p" and two == "P" or "p" :
  print("Draw, no one wins!")
elif one == "P" or "p"  and two == "R" or "r":
  print("Player 1's paper smothers Player 2's rock!")
elif one == "P" or "p"  and two == "S" or "s":
  print("Player 2's scissors cut Player 1's paper to shreds!")
elif one == "S" or "s"  and two == "R" or "r":
  print("Player 2's rock smashes Player 1's scissors!")

elif one == "S" or "s" and two == "P" or "p":
  print("Player 1's scissors shred Player 2's paper to shreds")
else:
  print("Use R, P, or S next time" )

That’s the point, so the other player can’t cheat.

So in Python, a non-empty string is always True. And Python is reading this like

if (one == "R") or ("r")

Since "r" will return True, it doesn’t care what the users inputted. Instead, use the .upper() method (makes the input uppercase, no matter what was actually inputted) like so:

one = input("Player 1 > ").upper()
two = input("Player 2 > ").upper()

if one == "R" and two == "P":
  print("Player 2's paper smothers Player 1's rock!")
elif one == "R" and two == "S":
  print("Player 1's rock smashes Player 2's scissors!")
elif one == two:
  print("Draw, no one wins!")
elif one == "P" and two == "R":
  print("Player 1's paper smothers Player 2's rock!")
elif one == "P" and two == "S":
  print("Player 2's scissors cut Player 1's paper to shreds!")
elif one == "S" and two == "R":
  print("Player 2's rock smashes Player 1's scissors!")

elif one == "S" and two == "P":
  print("Player 1's scissors shred Player 2's paper to shreds")
else:
  print("Use R, P, or S next time" )

I made the if statements a bit shorter, by the way.

1 Like

Thanks for the help :grinning:

1 Like