-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
42 lines (32 loc) · 1.04 KB
/
main.py
File metadata and controls
42 lines (32 loc) · 1.04 KB
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
import random
# computer chose any random number
computer = random.choice([0, 1, 2])
#Ask user choice
print('Keys: S = Snake, W = Water, G = Gun')
you = input("Enter your Choice: ").lower()
#It assign keys to the values
youDict = {"s": 0, "w": 1, "g": 2}
reverseDict = {0: "Snake", 1: "Water", 2: "Gun"}
#It check user input is valid or not
if you not in youDict:
print("Invalid Choice!")
exit()
youchose = youDict[you]
#It tell us user and computer choice
print(f"You Chose: {reverseDict[youchose]}\nComputer Chose: {reverseDict[computer]}")
if(computer == youchose):
print("It's a Draw!")
elif(computer == 1 and youchose == 2):
print("You Lose!")
elif(computer == 1 and youchose == 0):
print("You Win!")
elif(computer == 0 and youchose == 2):
print("You Win!")
elif(computer == 0 and youchose == 1):
print("You Lose!")
elif(computer == 2 and youchose == 0):
print("You Lose!")
elif(computer == 2 and youchose == 1):
print("You Win!")
else:
print("Something went wrong!")