Game of paper, scissors, stone

The famous game of paper, scissors, stone
This commit is contained in:
tk20blue 2021-01-11 03:53:25 +00:00 committed by GitHub
parent 8ddae6b56f
commit dfba4d339e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

62
GAME-paper-scissors-stone Normal file
View File

@ -0,0 +1,62 @@
import random
outcomes = ["Paper", "Scissors", "Stone"]
userscore = 0
botscore = 0
while True:
try:
games = int(input("How many games would you like to play? "))
break
except:
print("That isn't a valid number")
user_to_move = {"a": "Paper", "b" : "Scissors", "c" : "Stone"}
valid_enteries = ("a", "b", "c")
while userscore < games and botscore < games:
while True:
try:
user_answer = user_to_move[
input("\nEnter your choice: (a) Paper, (b) Scissors, (c) Stone \nEnter your letter: ")]
if user_answer == "a" or "b" or "c":
break
except:
print("Invalid input, please try again.")
print("Your answer is: " + user_answer)
bot_answer = random.choice(outcomes)
print("The bot answered: " + bot_answer)
def game_result(useranswer, bot_answer):
if useranswer == bot_answer:
return "Draw"
elif useranswer == "Stone" and bot_answer == "Scissors":
return "You Win!"
elif useranswer == "Paper" and bot_answer == "Stone":
return "You Win!"
elif useranswer == "Scissors" and bot_answer == "Paper":
return "You Win!"
elif useranswer == "Stone" and bot_answer == "Paper":
return "You Lose!"
elif useranswer == "Paper" and bot_answer == "Scissors":
return "You Lose!"
elif useranswer == "Scissors" and bot_answer == "Stone":
return "You Lose!"
else: return "Error"
if game_result(user_answer, bot_answer) == "You Win!":
userscore += 1
elif game_result(user_answer, bot_answer) == "You Lose!":
botscore += 1
else: pass
print(game_result(user_answer, bot_answer))
print(f'Your score is {userscore} and the bot score is {botscore}')
if userscore > botscore:
print("\nFINAL RESULT : YOU'RE A WINNER ! HURRAH !")
else:
print("\nFINAL RESULT: YOU DIDN'T WIN. TRY AGAIN.")