-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise22.py
More file actions
31 lines (21 loc) · 816 Bytes
/
Copy pathExercise22.py
File metadata and controls
31 lines (21 loc) · 816 Bytes
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
def rpsWinner(player1: str, player2: str) -> str:
if (
(player1 == "rock" and player2 == "scissors")
or (player1 == "paper" and player2 == "rock")
or (player1 == "scissors" and player2 == "paper")
):
return "player one"
elif player1 == player2:
return "tie"
else:
return "player two"
...
assert rpsWinner("rock", "paper") == "player two"
assert rpsWinner("rock", "scissors") == "player one"
assert rpsWinner("paper", "scissors") == "player two"
assert rpsWinner("paper", "rock") == "player one"
assert rpsWinner("scissors", "rock") == "player two"
assert rpsWinner("scissors", "paper") == "player one"
assert rpsWinner("rock", "rock") == "tie"
assert rpsWinner("paper", "paper") == "tie"
assert rpsWinner("scissors", "scissors") == "tie"