-
-
Save codecademydev/7e0b70cd9a7177c8c7bae6feb9496173 to your computer and use it in GitHub Desktop.
Codecademy export
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
""" | |
This is a rock paper scissors game meant for one person to be played against the computer | |
""" | |
from random import randint | |
options = ['ROCK', 'PAPER', 'SCISSORS'] | |
message = {"tie": "Yawn it's a tie!", | |
"won": "Yay you won!", | |
"lost": "Aww you lost!"} | |
def decide_winner(user_choice, computer_choice): | |
print "Your choice is %s" % (user_choice) | |
print "Computer choice is %s" % (computer_choice) | |
if user_choice == computer_choice: | |
print message["tie"] | |
elif user_choice == 'ROCK' and computer_choice == 'SCISSORS': | |
return message["won"] | |
elif user_choice == 'PAPER' and computer_choice == 'ROCK': | |
return message["won"] | |
elif user_choice == "SCISSORS" and computer_choice == "PAPER": | |
return message["won"] | |
else: | |
return message["lost"] | |
def play_RPS(): | |
user_choice = raw_input("Enter Rock, Paper or Scissors: ") | |
computer_choice = options[randint(0,2)] | |
decide_winner(user_choice,computer_choice) | |
play_RPS() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment