import random
def gameres(comp, you):
if comp == you:
return None
# when comp = r
elif comp == 'r':
if you == 'p':
return True
elif comp == 'r':
if you == 's':
return False
# when comp = p
elif comp == 'p':
if you == 's':
return True
elif comp == 'p':
if you == 'r':
return False
# when comp = s
elif comp == 's':
if you == 'r':
return True
elif comp == 's':
if you == 'p':
return False
print("Comp turn: Rock(r), Paper(p) and Scissor(s)")
randno = random.randint(1, 3)
if randno == 1:
comp = 'r'
elif randno == 2:
comp = 'p'
elif randno == 3:
comp = 's'
you = input("Your turn: Rock(r), Paper(p) and Scissor(s)")
a = gameres(comp, you)
print(f"Computer chose {comp}")
print(f"You chose {you}")
if a == None:
print("The game is a tie!")
elif a == True:
print("You Win!")
elif a == False:
print("You Lose!")
I tried to create a rock paper and scissor game in Python but I'd seen a problem whenever I should lose, it returns "The game is a tie".
I think it is always returning None instead of False.