forked from Revnth/Hacktoberfest2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrock_paper_scissor.py
38 lines (32 loc) · 1010 Bytes
/
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
import random
user_points = 0
computer_points = 0
options = ["rock","paper","scissors"]
while True:
user_input = input("Type Rock/paper/Scissors or Q to quit: ").lower()
if user_input == "q":
break
if user_input not in options:
continue
random_number = random.randint(0,2)
# rock : 0 , paper : 1 , scissors : 2
computer_pick = options[random_number]
print("Computer picked", computer_pick)
if(user_input == "rock" and computer_pick == "scissors"):
print("You won!")
user_points += 1
continue
elif(user_input == "paper" and computer_pick == "rock"):
print("You won!")
user_points += 1
continue
elif(user_input == "scissors" and computer_pick == "paper"):
print("You won!")
user_points += 1
continue
else:
print("You lost!")
computer_points += 1
print("You won",user_points,"times")
print("Computer won",computer_points,"times")
print("Goodbye!")