Created
April 20, 2020 09:50
-
-
Save Deep18-03/12e36ce35d8271eea599b4711f48c7a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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