Skip to content

Instantly share code, notes, and snippets.

@Deep18-03
Created April 20, 2020 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Deep18-03/12e36ce35d8271eea599b4711f48c7a6 to your computer and use it in GitHub Desktop.
Save Deep18-03/12e36ce35d8271eea599b4711f48c7a6 to your computer and use it in GitHub Desktop.
#snake water gun
import random
user_option={1:'snake',2:'water',3:'gun'}
option=['water','snake','gun',]
choice=random.choice(option)
def compare(user_ch,comp_ch):
"""This function compare the input of user and computer generated input and declare the winner """
if comp_ch==user_option[user_ch]:
print("game tie")
elif comp_ch=='snake':
if user_option[2]:
print("snake win")
else:
print("gun win")
elif comp_ch=='water':
if user_option[1]:
print("snake win")
else:
print("water win")
else:
if user_option[1]:
print("gun win")
else:
print("water win")
no=1
for i in option:
print(str(no) + "." + i)
no=no+1
user=int(input("enter yout choice"))
compare(user,choice)
print("\nUser choice is "+user_option[user]+"\ncomputer choice is "+choice)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment