-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.py
More file actions
29 lines (29 loc) · 1.04 KB
/
game.py
File metadata and controls
29 lines (29 loc) · 1.04 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
import random
def get_choices():
player_choice=input('Enter your choice("rock","paper","scissors"):')
option=["rock","paper","scissors"]
computer_choice=random.choice(option)
choices={"player":player_choice,"computer":computer_choice}
return choices
def check_win(player,computer):
print("You chose "+ player+ " Computer chose " + computer)
if player==computer:
return "It is a tie!"
elif(player=="rock"):
if(computer=="paper"):
return "Paper covers rock.You loose!"
else:
return "Rock smashes scissors.You win!!"
elif(player=="paper"):
if(computer=="rock"):
return "Paper covers rock.You win!!"
else:
return "Scissors cuts paper.You loose!"
elif(player=="scissors"):
if(computer=="rock"):
return "Rock smashes scissors.You loose!"
else:
return "Scissors cuts paper.You win!!"
choices=get_choices()
result=check_win(choices["player"],choices["computer"])
print(result)