-
Notifications
You must be signed in to change notification settings - Fork 0
/
manual_rps.py
50 lines (40 loc) · 1.26 KB
/
manual_rps.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import random
def get_computer_choice():
cGuess = random.choice(["Rock","Paper","Scissors"])
return cGuess
def get_user_choice():
while True:
guess = input("Please choose your play: ")
try:
if guess in ["Rock","Paper","Scissors"]:
break
else:
print("Invalid Choice. Please choose from:", ["Rock","Paper","Scissors"])
except:
print("Invalid Choice. Please choose from:", ["Rock","Paper","Scissors"])
return guess
def get_winner(computer_choice, user_choice):
if computer_choice == "Rock":
if user_choice == "Rock":
print("It is a tie!")
elif user_choice == "Paper":
print("You won!")
else:
print("You lost")
elif computer_choice == "Paper":
if user_choice == "Rock":
print("You lost")
elif user_choice == "Paper":
print("It is a tie!")
else:
print("You won!")
else:
if user_choice == "Rock":
print("You won!")
elif user_choice == "Paper":
print("You lost")
else:
print("It is a tie!")
def play():
get_winner(get_computer_choice(),get_user_choice())
play()