-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10_04_rock_paper_scissors.py
More file actions
49 lines (45 loc) · 1.35 KB
/
10_04_rock_paper_scissors.py
File metadata and controls
49 lines (45 loc) · 1.35 KB
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
# write rock-paper-scissors game
# have the user play against the computer
# you can use the random library to select an option for the computer
# use a while loop so the user can play until they win
import random
computer_choice = random.randint(1, 3)
# you can map each of rock / paper / scissors to an integer from 1 - 3
import random
computer_choice = random.randint(1, 3)
print("rock = 1 \npaper = 2 \nscissors = 3 \n")
status=0
while(status==0):
i=input("enter the choice: ")
i=int(i)
if(i):
print(computer_choice)
if(computer_choice==1):
if(i==1):
print("invalid")
continue
elif(i==3):
print("computer won")
continue
else:
print("You won!")
status=1
elif(computer_choice==2):
if(i==2):
print("invalid")
continue
elif(i==1):
print("computer won")
continue
else:
print("You won!")
status=1
else:
if(i==3):
print("invalid")
continue
elif(i==2):
print("computer won")
continue
else:
print("You won!")