forked from kishanrajput23/Awesome-Python-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnake_water_gun.py
52 lines (43 loc) · 1.79 KB
/
Snake_water_gun.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
# We have 3 choice for selecting snake, water, function
# we have selected anything from 3 choices
# computer choose randomly among three choices
# if I choose snake and computer choose water then snake win
# if I choose snake and computer choose gun then gun win
# if I choose snake and computer choose snake then match draw
# if I choose gun and computer choose water then water win
# if I choose gun and computer choose water then gun win
# if I choose gun and computer choose water then gun match tie
# if I choose water and computer choose gun then water won
# if I choose water and computer choose snake then snake won
# if I choose water and computer choose water then draw
import random
score = 0
i = 1
while i <= 5:
computer_guesses = ['snake', 'water', 'gun']
print(f"{i}. Computer has choose value....")
compChoice = random.choice(computer_guesses)
print("Choose any one from snake, water, gun ")
myChoice = input()
if myChoice == "snake" or myChoice == "water" or myChoice == "gun":
if myChoice == 'snake' and compChoice == 'water':
print("You win!!")
score += 1
elif myChoice == 'snake' and compChoice == 'gun':
print("You lost!!")
elif myChoice == 'water' and compChoice == 'gun':
print("You win!!")
score += 1
elif myChoice == 'water' and compChoice == 'snake':
print("You lost!!")
elif myChoice == 'gun' and compChoice == 'snake':
print("You win!!")
score += 1
elif myChoice == 'gun' and compChoice == 'water':
print("You lost!!")
else:
print("Match draw!!")
i += 1
else:
print("Enter valid input...")
print("\nYour Total score: ", score)