Skip to content

Instantly share code, notes, and snippets.

@keshavsaharia
Created March 9, 2014 22:27
Show Gist options
  • Save keshavsaharia/9455888 to your computer and use it in GitHub Desktop.
Save keshavsaharia/9455888 to your computer and use it in GitHub Desktop.
RPS
import random
currentround = 0
rounds = 5
while currentround < rounds:
currentround + 1
answer = input("Select rock paper or scissors")
while answer != "rock" and answer != "paper" and answer != "scissors":
print "Bad answer"
answer = input("Select rock paper or scissors")
rolled = random.randint(1, 3)
computer = "blah"
if rolled == 1:
computer = "rock"
if rolled == 2:
computer = "paper"
if rolled == 3:
computer = "scissors"
print "I chose " + answer
print "Computer picked " + computer
if answer == "scissors" and computer == "paper":
print "Scissors beats paper, I win!"
if answer == "scissors" and computer == "rock":
print "Rock beats scissors, you lose!"
if answer == "scissors" and computer == "scissors":
print "There was a tie."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment