How do I add winning conditions to this rock paper scissors code in python? Please keep it simple as I am not allowed to include code we have not learned yet.

import random
choice = input("Enter Rock(R), Paper(P), or Scissors(S): ")
computer = random.randint(1, 3)
if computer == 1:
print("Computer played R.")
elif computer == 2:
print("Computer played P.")
else:
print("Computer played S.")

Respuesta :

Answer:

You wanted simple, but i dodn't know how simple you wanted so I kept it as simple as possible, don't blame me if theres a bug.

Explanation:

import random

choice = input("Enter Rock(R), Paper(P), or Scissors(S): ")

computer = random.randint(1, 3)

if computer == 1 and choice == "R":

   print("Computer played Rock.")

   print("Tie")

elif computer == 2 and choice == "P":

   print("Computer played Paper.")

   print("Tie")

elif computer == 3 and choice == "S":

   print("Computer played Scissors.")

   print("Tie")

elif computer == 1 and choice == "S":

   print("Computer played Rock.")

   print("You Lose")

elif computer == 2 and choice == "R":

   print("Computer played Paper.")

   print("You Lose")

elif computer == 3 and choice == "P":

   print("Computer played Scissors.")

   print("You Lose")

elif computer == 1 and choice == "P":

   print("Computer played Rock.")

   print("You Win")

elif computer == 2 and choice == "S":

   print("Computer played Paper.")

   print("You Win")

elif computer == 3 and choice == "R":

   print("Computer played Scissor.")

   print("You Win")