-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRock-P.py
More file actions
40 lines (30 loc) · 1.01 KB
/
Rock-P.py
File metadata and controls
40 lines (30 loc) · 1.01 KB
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
34
35
36
37
38
39
40
import random
game_choice= ["rock", "paper", "scissor"]
def get_choices():
player_choice = input("Enter a choice(rock, paper, scissor):")
computer_choice = random.choice(game_choice)
global choices
choices = {"player": player_choice, "computer": computer_choice}
return choices
def check_win(computer, player):
print(f"You chose {player}, computer chose {computer}")
if (computer==player):
print ("It's a tie!")
elif (computer== "paper"):
if (player=="scissor"):
return 'Scissor cuts paper! You are winner'
else:
return 'Paper covers rock! You are loser'
elif (player== "paper"):
if (computer=="scissor"):
return 'Scissor cuts paper! computer wins'
else:
return 'Paper covers rock! computer loses'
elif (player== "rock"):
if (computer=="scissor"):
return 'rock broke scissor! you win!'
else:
return 'Paper covers rock! computer wins'
get_choices()
result= check_win(choices["player"], choices["computer"])
print(result)