Image Credit: Wikimedia
p1 = input("Enter \"rock\", \"paper\", or \"scissors\" for player 1: ")
p2 = input("Enter \"rock\", \"paper\", or \"scissors\" for player 2: ")
# determine the winner
Player 1 | Player 2 | Output |
---|---|---|
rock | rock | tie |
rock | paper | player 2 wins |
rock | scissors | player 1 wins |
paper | rock | player 1 wins |
paper | paper | tie |
paper | scissors | player 2 wins |
scissors | rock | player 2 wins |
scissors | paper | player 1 wins |
scissors | scissors | tie |
p1 = input("Enter \"rock\", \"paper\", or \"scissors\" for player 1: ")
p2 = input("Enter \"rock\", \"paper\", or \"scissors\" for player 2: ")
if p1 == "rock" and p2 == "rock":
print("tie")
if p1 == "rock" and p2 == "paper":
print("player 2 wins")
if p1 == "rock" and p2 == "scissors":
print("player 1 wins")
if p1 == "paper" and p2 == "rock":
print("player 1 wins")
if p1 == "paper" and p2 == "paper":
print("tie")
if p1 == "paper" and p2 == "scissors":
print("player 2 wins")
if p1 == "scissors" and p2 == "rock":
print("player 2 wins")
if p1 == "scissors" and p2 == "paper":
print("player 1 wins")
if p1 == "scissors" and p2 == "scissors":
print("tie")
if (not (p1 == "rock" or p1 == "paper" or p1 == "scissors") or
not (p2 == "rock" or p2 == "paper" or p2 == "scissors")):
print("error")
p1 = input("Enter \"rock\", \"paper\", or \"scissors\" for player 1: ")
p2 = input("Enter \"rock\", \"paper\", or \"scissors\" for player 2: ")
if ((p1 == "rock" and p2 == "rock") or
(p1 == "paper" and p2 == "paper") or
(p1 == "scissors" and p2 == "scissors")):
print("tie")
if ((p1 == "rock" and p2 == "paper") or
(p1 == "paper" and p2 == "scissors") or
(p1 == "scissors" and p2 == "rock")):
print("player 2 wins")
if ((p1 == "rock" and p2 == "scissors") or
(p1 == "paper" and p2 == "rock") or
(p1 == "scissors" and p2 == "paper")):
print("player 1 wins")
if (not (p1 == "rock" or p1 == "paper" or p1 == "scissors") or
not (p2 == "rock" or p2 == "paper" or p2 == "scissors")):
print("error")