My Snake Game Source Code :


import random

def game(a , oppoints , mypoints,chances):
    while(True):
        if chances == 0:
            break

        if mypoints == 10 :
            print("you won")
            break

        if oppoints == 10:
            print("your opponent won")
            break

       
        if a == 1:
            getting_input = str(input("snake ,gun and water : "))
            print(getting_input)
        lst = ["Gun","snake","water"]
        choice = random.choice(lst)
        print(choice)
        if getting_input == "snake" and choice == lst[0]:
            print("Your Oponent got lead !!")
           
            oppoints = oppoints + 1
            print("Your Oponent point score is",oppoints)
            chances = chances - 1
            print(chances)
            print("Your chances discremented by one , hence chances are",chances)
         

        elif getting_input == "gun" and choice == lst[1]:
            print("Your got the lead !!")
           
            mypoints = mypoints + 1
            print(mypoints)
            print("Your score is",mypoints)

        elif getting_input == "snake" and lst[2]:
            print("You got the lead Again !! ")
            mypoints = mypoints + 1
            print("your score is" , mypoints)

       
        elif getting_input == "water" and lst[1]:
            print("Your opponent got the lead Again !! ")
            oppoints = oppoints + 1
            print("your opponent score is" , oppoints)
            chances = chances - 1
            print("Your chances discremented by one, hence your chances are" , chances)


        elif getting_input == "water" and lst[0]:
            print("You got the lead Again !! ")
            mypoints = mypoints + 1
            #print("Your chances discremented by one, hence your chances are" , chances)
            print("your score is" , mypoints)

        elif getting_input == "gun" and lst[2]:
            print("Your opponent got the lead Again !! ")
            oppoints = oppoints + 1
            print("your opponent score is" , oppoints)
            chances = chances - 1
            print("Your chances discremented by one, hence your chances are" , chances)
       
   
       
       
       
       
       
print("Welcome to The snake game")
a = int(input("Press one for play : "))
oppoints = 0
mypoints = 0
chances = 10
game(a,oppoints, mypoints,chances)










       

           
         
           









Post a Comment

Previous Post Next Post