-
Notifications
You must be signed in to change notification settings - Fork 0
/
python_rock_paper_scissors_game.py
41 lines (37 loc) · 1.12 KB
/
python_rock_paper_scissors_game.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
import random
computer=['rock','paper','scissors']
def play(user,computer):
#a=random.randint(0,2)
choice=random.choice(computer)
print("Computer: ",choice)##we could also use #computer[a]
if(user=="rock"):
if (choice=="scissors"):
print("User won.")
elif(choice=="paper"):
print("User lost.")
else:
print("It is a tie.")
elif(user=="paper"):
if (choice=="scissors"):
print("User lost.")
elif(choice=="rock"):
print("User won.")
else:
print("It is a tie.")
elif(user=="scissors"):
if (choice=="rock"):
print("User lost.")
elif(choice=="paper"):
print("User won.")
else:
print("It is a tie.")
user=""
while (user not in computer):
user=str(input("Enter:\n1.Rock\n2.Paper\n3.Scissors\n"))
print("________________________________________________________________________")
if (user in computer):
print("User: ",user)
play(user,computer)
break
else:
print("Not a valid one.Try again...\n")