def greater_less_equal_5(answer):

if answer != 5 :

return 1

elif answer == 5:

return -1

else:

return 0

print greater_less_equal_5(4)

print greater_less_equal_5(5)

print greater_less_equal_5(6)

def greater_less_equal_5(answer):

if answer != 5 :

return 1

elif answer == 5:

return -1

else:

return 0

print greater_less_equal_5(4)

print greater_less_equal_5(5)

print greater_less_equal_5(6)

you are pretty close, but `!=`

and `==`

are not the right comparison operators

we need to check if answer is greater then 5, else if check answer is smaller then 5

use the right comparison operators, what are the comparison operator for greater then? What is the comparison operator for smaller then?

def greater_less_equal_5(answer):

if answer >= 5 :

return 1

elif answer <= 5:

return -1

else:

return 0

print greater_less_equal_5(4)

print greater_less_equal_5(5)

print greater_less_equal_5(6)

the exercise approves this? `>=`

means greater then or equal to, please use greater then (`>`

) operator

so then the function doesn't return the right value when `answer=5`

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.