Created
October 24, 2014 17:47
-
-
Save shashisp/ca111827f99c045aa96d to your computer and use it in GitHub Desktop.
simple rock paper scissor game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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