You are indeed missing something basic – namely, that the output of your function doesn’t depend on answer
at all. No matter what you feed in as answer
, because 6 > 5
is always True
, it will always return the result of that case.
What you need is
def greater_less_equal_5(answer):
if answer > 5:
return 1
elif answer < 5:
return -1
elif answer == 5:
return 0
1
solved Issue with if-else statements [closed]