-
-
Save codecademydev/d91db682cac6dd1968e7d33baa8f74bc 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.""" | |
from random import randit | |
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: " + user_choice) | |
print("The Computer selected: " + 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 Scissor: ") | |
user_choice = user_choice.upper() | |
computer_choice = options[randit(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