Snake, Water Or Gun Game Using Python

 Snake, Water Or Gun Game Using Python :

import random

def gameWin(comp, you):
    if comp == you:
        return None
    elif comp == 's':
        if you == 'w':
            return False
        elif you == 'g':
            return True
    elif comp == 'w':
        if you == 'g':
            return False
        elif you == 's':
            return True
    elif comp == 'g':
        if you == 's':
            return False
        elif you == 'w':
            return True

print("Computer's Turn: Snake(s), Water(w), or Gun(g)?")
randNo = random.randint(1, 3)
if randNo == 1:
    comp = 's'
elif randNo == 2:
    comp = 'w'
elif randNo == 3:
    comp = 'g'

you = input("Your Turn: Snake(s), Water(w), or Gun(g)?")
print(f"Computer chose {comp}")
print(f"You chose {you}")

result = gameWin(comp, you)

if result == None:
    print("The game is a tie!")
elif result:
    print("You win!")
else:
    print("You lose!")

Comments

Popular posts from this blog

Write A Python Program, Create n Empty Dictionary Allow 4 Friends To, Enter Their Favorite Programming Language As values and User Keys as their Name Assume That The Names Are Unique.

Write Python Program To Store Seven Fruits Name In a List Enter By The User