Skip to content

Instantly share code, notes, and snippets.

@shashisp
Created October 24, 2014 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shashisp/ca111827f99c045aa96d to your computer and use it in GitHub Desktop.
Save shashisp/ca111827f99c045aa96d to your computer and use it in GitHub Desktop.
simple rock paper scissor game
from random import choice
name = raw_input("Enter your name : ")
rps = ['r','p','s']
u = 0
c = 0
while 1:
print "R: Rock, P: Paper, S: Scissor"
user = raw_input("Enter your choice among the three : ")
user = user.lower()
comp = choice(rps)
if user == comp:
print "Its a Tie!"
elif user == 'r' and comp == 's':
print 'You entered Rock. I had Scissor. You win!'
u+=1
elif user == 'r' and comp == 'p':
print 'You entered Rock. I had Paper. You lose!'
c+=1
elif user == 's' and comp == 'p':
print 'You entered Scissor. I had Paper. You win!'
u+=1
elif user == 's' and comp == 'r':
print 'You entered Scissor. I had Rock. You lose!'
c+=1
elif user == 'p' and comp == 's':
print 'You entered Paper. I had Scissor. You lose!'
c+=1
elif user == 'p' and comp == 'r':
print 'You entered Paper. I had Rock. You win!'
u+=1
if c == 5:
print "Computer Wins!"
break
elif u == 5:
print "Congratulations "+ name
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment