-
Notifications
You must be signed in to change notification settings - Fork 0
/
rock-paper-scissor.py
46 lines (31 loc) · 1.06 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
36
37
38
39
40
41
42
43
44
45
import random
print("\nHey there, Let's play rock paper scissor!\n\n")
user_score = 0
bot_score = 0
options = ["rock", "paper", "scissor"]
while True:
user_choice = input("\nPlease enter one of the following: rock/paper/scissor, or Q to exit the game: ").lower()
if user_choice == "q":
break
if user_choice not in options:
print("Please select a valid option.\n ")
continue
computer_choice = random.choice(options)
# 0 = rock, 1 = paper, 2 = scissor
print("Computer chose", computer_choice + ".")
if user_choice == "rock" and computer_choice == "scissor":
print("You won!")
user_score += 1
elif user_choice == "paper" and computer_choice == "rock":
print("You won!")
user_score += 1
elif user_choice == "scissor" and computer_choice == "paper":
print("You won!")
user_score += 1
else:
print("Computer won...")
bot_score += 1
continue
print("\nYour score is:", user_score)
print("Computer score is:", bot_score)
print("\nGoodbye!")