- 3

Why this code doesn't work perfectly plz help

import random def game(comp,u): if comp=="snake": if u=="water": return False else: return True elif comp=="gun": if u=="snake": return True else: return False elif comp=="water": if u=="gun": return False else: return True elif comp==u: return None print() com=(" choose gun, water, or snake") randomno=random.randint(1,3) #print(randomno) if randomno==1: computer="gun" elif randomno==2: computer="water" elif randomno==3: computer="snake" you=str(input("choose any one gun, water, or snake -->")) a=game(computer,you) print(f"computer choose --> {computer}") print(f"you choose --> {you}") if a==None: print("game tie") elif a==True: print("you won") elif a==False: print("you lose")

5th May 2021, 1:43 PM
Divyansh Rathore
Divyansh Rathore - avatar
4 Antworten
0
Could i please know where the problem is exactly. Is it an error, or is it not doing what you want?
5th May 2021, 3:21 PM
Kamil Hamid
Kamil Hamid - avatar
0
There is no error but i didn't get desire output
6th May 2021, 4:31 AM
Divyansh Rathore
Divyansh Rathore - avatar
0
Could i please know what the aim is?
6th May 2021, 3:25 PM
Kamil Hamid
Kamil Hamid - avatar
0
Did you ever played snake, water and gun game Or stone, paper, scissors game
6th May 2021, 3:28 PM
Divyansh Rathore
Divyansh Rathore - avatar