-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.py
32 lines (31 loc) · 957 Bytes
/
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
import random
def game():
ch=["rock","paper","scissors"]
computer=random.choice(ch)
user=input("Enter choice(rock, paper, scissors)")
print("Computer choosed",computer)
if user not in ch:
print("Wrong input, please restart the game.")
game()
elif user==computer:
print("It's a tie.")
replay=input("Want to replay? (y/n)")
if replay=="y" or replay=="Y":
game()
else:
exit()
elif (user=="paper" and computer=="rock") or (user=="scissors" and computer=="paper") or (user=="rock" and computer=="scissors"):
print("You won!")
replay=input("Want to replay? (y/n)")
if replay=="y" or replay=="Y":
game()
else:
exit()
else:
print("Computer wins!")
replay=input("Want to replay? (y/n)")
if replay=="y" or replay=="Y":
game()
else:
exit()
game()