Skip to content

Instantly share code, notes, and snippets.

@cyvax
Created March 21, 2021 19:13
Show Gist options
  • Save cyvax/f4e72438b00cfa387f380b7f63e20be3 to your computer and use it in GitHub Desktop.
Save cyvax/f4e72438b00cfa387f380b7f63e20be3 to your computer and use it in GitHub Desktop.
Rock-Paper-Scissors.py
# Write your code here
from random import choice
while True:
user_choice = input()
win_situation = {"rock": "scissors",
"paper": "rock",
"scissors": "paper"}
computer_choice = choice(list(win_situation.keys()))
if user_choice not in win_situation.keys():
msg = "Invalid input"
if user_choice == "!exit":
print("Bye!")
exit(0)
elif user_choice == computer_choice:
msg = f"There is a draw ({computer_choice})"
elif win_situation[user_choice] != computer_choice:
msg = f"Sorry, but computer chose {computer_choice}"
else:
msg = f"Well done. Computer chose {computer_choice} and failed"
print(msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment