Created
September 25, 2012 11:57
-
-
Save pdpinch/3781336 to your computer and use it in GitHub Desktop.
6.189 Exercise 1.7
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
# Exercise 1.7 | |
# Rock, Paper Scissors game | |
## TODO: lower case user input | |
player1 = raw_input('Player 1? ') | |
# make sure player1's play is one of rock, paper or scissors | |
while (player1 != 'rock' and player1 != 'paper' and player1 != 'scissors'): | |
print "You wrote: " + player1 | |
player1 = raw_input('Please enter one of the following, "rock", "paper" or "scissors": ') | |
player2 = raw_input('Player 2? ') | |
# make sure player2's play is one of rock, paper or scissors | |
while (player2 != 'rock' and player2 != 'paper' and player2 != 'scissors'): | |
print "You wrote: " + player2 | |
player2 = raw_input('Please enter one of the following, "rock", "paper" or "scissors: ') | |
if (player1 == 'rock'): | |
# rock stuff | |
if (player2 == 'rock'): | |
print 'Tie!' | |
elif (player2 == 'paper'): | |
print 'Player 2 wins!' | |
elif (player2 == 'scissors'): | |
print 'Player 1 wins!' | |
else: | |
print 'Something went wrong' | |
elif (player1 == 'scissors'): | |
# scissors stuff | |
if (player2 == 'rock'): | |
print 'Player 2 wins!' | |
elif (player2 == 'paper'): | |
print 'Player 1 wins!' | |
elif (player2 == 'scissors'): | |
print 'Tie!' | |
else: | |
print 'Something went wrong' | |
elif (player1 == 'paper'): | |
#paper stuff | |
if (player2 == 'rock'): | |
print 'Player 1 wins!' | |
elif (player2 == 'paper'): | |
print 'Tie!' | |
elif (player2 == 'scissors'): | |
print 'Player 2 wins!' | |
else: | |
print 'Something went wrong' | |
else: | |
print "Something went wrong" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment