forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
31 lines (24 loc) · 879 Bytes
/
main.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
import utils
# import the random module
import random
print("Starting the Rock Paper Scissors game!")
player_name = input("Please enter your name: ") # Takes Input from the user
print("Pick a hand: (0: Rock, 1: Paper, 2: Scissors)")
while True:
try:
player_hand = int(input("Please enter a number (0-2): "))
if player_hand not in range(3):
raise ValueError
else:
break
except ValueError as e:
print("Please input a correct number")
if utils.validate(player_hand):
# Assign a random number between 0 and 2 to computer_hand using randint
computer_hand = random.randint(0, 2)
utils.print_hand(player_hand, player_name)
utils.print_hand(computer_hand, "Computer")
result = utils.judge(player_hand, computer_hand)
print("Result: " + result)
else:
print("Please enter a valid number")