-
Notifications
You must be signed in to change notification settings - Fork 1
/
snake_water_gun_code.py
73 lines (44 loc) · 1.3 KB
/
snake_water_gun_code.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import random
options = ['s', 'w' , 'g']
print("hello, welcome to snake , gun , water game !! please get ready !!")
n = int(input("enter your rounds which you want to play"))
round = 1
com_win = 0
usr_win = 0
while n >= round :
print(f"round : {round} \nsnake - s \nwater - w \nGun - g\n ")
try:
player = input("choose your option")
except EOFError as e:
print(e)
if player!='s' and player != 'w' and player != 'g':
print("invalid entry ! plese check your input and try again")
continue
computer = random.choice(options)
if computer == 's':
if player == 'w' :
com_win += 1
elif player == 'g':
usr_win += 1
elif computer == 'w':
if player == 'g':
com_win += 1
elif player == 's':
usr_win += 1
elif computer == 'g':
if player == 's':
com_win += 1
elif player == 'w':
usr_win += 1
if usr_win > com_win :
print(f"usr won round{round}")
elif usr_win < com_win :
print(f"computer won {round}")
else: print("draw")
round += 1
if usr_win > com_win :
print("congratulation usr you won")
elif com_win > usr_win:
print("you lose usr ! sorry for your lose")
else :
print("draw!!")