Created
September 19, 2022 20:21
-
-
Save Ichinga-Samuel/525423ffddfb856f8c5b661a2ac6fa3e to your computer and use it in GitHub Desktop.
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
from random import choice | |
game_state = {"R": "Rock", "P": "Paper", "S": "Scissors"} | |
options = list(game_state.keys()) | |
winnings = ["RS", "PR", "SP"] | |
result = "{0} beats {1}" | |
while True: | |
computer = choice(options) | |
player = input("Enter R for Rock , P for Paper, S for Scissors, and, done to quit the game: ").upper() | |
if player == "DONE": | |
print("Game Over") | |
break | |
elif player not in options: | |
print("Wrong choice, Pick again. Rock, Paper or Scissors?") | |
continue | |
elif player == computer: | |
print("Tie!, Here we go again!") | |
continue | |
else: | |
move = player+computer | |
winner, winner_move, looser_move = ("Player", player, computer) if move in winnings else ("Computer", computer, player) | |
print(f"{winner} Won!", result.format(game_state[winner_move], game_state[looser_move])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment