-
Notifications
You must be signed in to change notification settings - Fork 0
/
rock_paper_scissor.py
35 lines (29 loc) · 1.04 KB
/
rock_paper_scissor.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
34
35
import random
def get_choices():
player_choice = input("Enter a choice (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 "It's a tie!"
elif player == "rock":
if computer == "scissors":
return "Rock smashes scissors! You win!"
else:
return "Paper covers rock! You lose."
elif player == "paper":
if computer == "rock":
return "Paper covers rock! You win!"
else:
return "Scissors cuts paper! You lose."
elif player == "scissors":
if computer == "paper":
return "Scissors cuts paper! You win!"
else:
return "Rock smashes scissors! You lose."
choices = get_choices()
result = check_win(choices["player"], choices["computer"])
print(result)