rock paper scissors python while loop code example

Example: python rock paper scissors

from random import randint
userA = input("Rock(R), Paper(P) or Scissors(S)")
comp = ["R", "P", "S"]
compA = comp[randint(0, 2)]
if userA == compA:
    print("Draw")
elif userA == "R" and compA == "P":
    print("You Lose")
elif userA == "R" and compA == "S":
    print("You Win")
elif userA == "S" and compA == "P":
    print("You Win")
elif userA == "S" and compA == "R":
    print("You Lose")
elif userA == "P" and compA == "R":
    print("You Win")
elif userA == "P" and compA == "S":
    print("You Lose")
else:
    print("ERROR")

Tags:

Misc Example