Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created December 28, 2018 10:00
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/6367f0e7df2ff989d999e843046a80e2 to your computer and use it in GitHub Desktop.
Save codecademydev/6367f0e7df2ff989d999e843046a80e2 to your computer and use it in GitHub Desktop.
Codecademy export
"""Welcome to
Rock-Paper-Scissors
Game!"""
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 "You selected: %s" % user_choice
print "Computer selected: %s" % computer_choice
if user_choice == computer_choice:
print message["tie"]
elif user_choice == options[0] and computer_choice == options[2]:
print message["won"]
elif user_choice == options[1] and computer_choice == options[0]:
print message["won"]
elif user_choice == options[2] and computer_choice == options[1]:
print message["won"]
else:
print message[lost]
def play_RPS():
user_choice = raw_input("Enter Rock, Paper, or Scissors: ").upper()
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