-
-
Save cyvax/f4e72438b00cfa387f380b7f63e20be3 to your computer and use it in GitHub Desktop.
Rock-Paper-Scissors.py
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
# 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