If else statement in Python, for the code shared my answer should be 1, -1 and 0 while am getting 1's


#1

def greater_less_equal_5(answer):
    if (15>5):
        return 1
    elif (4<5):          
        return -1
    else:
        return 0
        
print greater_less_equal_5(4)
print greater_less_equal_5(5)
print greater_less_equal_5(6)

#2

well 15 is always greater then 5, so your if statement is always true, so 1 gets always returned. I would compare your function parameter (answer) with 5 in both your if and elif


#3

@gigarunner53563 Please start indenting your code when you post. It will make it easier for us.


#4

I’m also having the same difficulty.