-
Notifications
You must be signed in to change notification settings - Fork 1
/
rps_game.py
35 lines (30 loc) · 1.04 KB
/
rps_game.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import random
def get_choice():
player_choice = input('chose "rock","paper","scissors": ')
options = ["rock", "paper", "scissors"]
computer_choice = random.choice(options)
choices = {"player": player_choice, "computer": computer_choice}
return choices
def check_win(player,computer):
print(f"you chose {player} computer chose {computer} ")
if player == computer:
return "Its a tie!"
elif player == "rock":
if computer == "paper":
return "Paper covers rock! You lose"
else:
return "Rock smashes scissors! You win!"
elif player == "paper":
if computer == "scissors":
return "Scissors cuts paper! You lose."
else:
return "Paper covers rock! You win!"
elif player == "scissors":
if computer == "rock":
return "Rock smashes scissors! You lose."
else:
return "Scissors cuts paper! You win!"
choices = get_choice()
result = check_win(choices["player"],choices["computer"])
print(result)
print('The end')