Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created January 28, 2019 10:16
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 codecademydev/7e0b70cd9a7177c8c7bae6feb9496173 to your computer and use it in GitHub Desktop.
Save codecademydev/7e0b70cd9a7177c8c7bae6feb9496173 to your computer and use it in GitHub Desktop.
Codecademy export
"""
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