-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
41 lines (36 loc) · 843 Bytes
/
main.py
File metadata and controls
41 lines (36 loc) · 843 Bytes
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
import random
def gamewin(comp,player):
if comp == player:
return None
elif comp == 's':
if player=='w':
return False
elif player=='g':
return True
elif comp=='g':
if player=='s':
return False
elif player=='w':
return True
elif comp=='w':
if player=='g':
return False
elif player=='s':
return True
randno=random.randint(1,3)
if randno==1:
comp='s'
elif randno==2:
comp='g'
else:
comp='w'
player=input("enter snake(s),gun(g) and water(w):\n")
a = gamewin(comp,player)
print(f"Computer choose {comp}")
print(f"You choose {player}")
if a==None:
print("You tie the game!")
elif a:
print("you win !")
else :
print("You loose !")