From 8404108629c5d92a4b2199b2f100caf48c8146df Mon Sep 17 00:00:00 2001 From: AnkurTyagi-09 Date: Sat, 8 Mar 2025 15:22:03 +0530 Subject: [PATCH] Add files via upload --- snake , water , gun game .py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 snake , water , gun game .py diff --git a/snake , water , gun game .py b/snake , water , gun game .py new file mode 100644 index 00000000..c6a40cca --- /dev/null +++ b/snake , water , gun game .py @@ -0,0 +1,32 @@ +# snake , water , gun game +import random +computer = random.choice([1, 0, -1]) + +x = input("Enter 's' for snake, 'w' for water, 'g' for gun: ") + +def youstr(x): + you_dict = {"s": -1, "w": 1, "g": 0} + reverse_dict = {-1: "snake", 1: "water", 0: "gun"} + you = you_dict[x] + return you, reverse_dict + +you, reverse_dict = youstr(x) + +print(f"You choose {reverse_dict[you]}\nComputer choose {reverse_dict[computer]}") + +if (computer == you): + print("Draw🫡") + +else: + if (computer == -1 and you == 1) : + print("You win🎉") + elif (computer == -1 and you == 0) : + print("You lose😭") + elif (computer == 1 and you == 0): + print("You win🎉") + elif (computer == 1 and you == -1): + print("You lose😭") + elif (computer == 0 and you == -1): + print("You win🎉") + elif (computer == 0 and you == 1): + print("You lose😭") \ No newline at end of file