Skip to content

Instantly share code, notes, and snippets.

@user21944
Last active April 26, 2023 15:33
Show Gist options
  • Save user21944/dc28ecbb283d836415b26bd618765272 to your computer and use it in GitHub Desktop.
Save user21944/dc28ecbb283d836415b26bd618765272 to your computer and use it in GitHub Desktop.
Better than elincyt
#!/usr/bin/env python
import random
C = ["rock", "paper", "scissors"]
c = random.randint(0,2)
while True:
x = input("1: rock, 2: paper, 3: scissors\n")
if x.isdigit():
x = int(x) - 1
if (x >= 0 and x <= 2): break
print("Please select a valid option:")
print("You picked " + C[x] + ", computer picked " + C[c] + ".")
if ((x + 1) % len(C) == c): print("Computer wins.")
elif ((x - 1) % len(C) == c): print("You win.")
elif (x == c): print("Tie.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment