Skip to content

Instantly share code, notes, and snippets.

@colbymorrison
Created January 11, 2019 05:42
Show Gist options
  • Save colbymorrison/3b4de3f825376536c7fdf479ea6f7d7e to your computer and use it in GitHub Desktop.
Save colbymorrison/3b4de3f825376536c7fdf479ea6f7d7e to your computer and use it in GitHub Desktop.
from random import randint
# Decides if the user or computer won
def decide_winner(user_choice, computer_choice):
print("You selected " + user_choice)
print("Computer selected " + computer_choice)
if user_choice=="R" and computer_choice=="S":
print("You Win!")
elif user_choice=="P" and computer_choice=="R":
print("You Win!")
elif user_choice=="S" and computer_choice=="P":
print("You Win!")
elif user_choice==computer_choice:
print("It's a tie!")
else:
print("You Suck!")
# Prompts user for a choice, chooses randomly for computer
# and calls decide_winner
def run_game():
options = ["R", "P", "S"]
user_input=input("Select Rock, Paper, or Scissors ")
computer_input=options[randint(0,2)]
decide_winner(user_input,computer_input)
run_game()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment