def greater_less_equal_5(answer):
if 3>1:
return 1
elif 1>3:
return -1
return 0

print greater_less_equal_5(4)
print greater_less_equal_5(5)
print greater_less_equal_5(6)
. what is my mistake in the codes above plz



Oops, try again. It looks like your function output 1 instead of -1 when answer is 3. Make sure you filled in the if and elif statements correctly!

the above is the error am getting


@davisalonzo21yahoo.c: Whenever posting a code on the forums, it's highly suggested that you use the code tag:

[code]#your code here[/code]

Okay so back to the problem. Based on your function, you were supposed to return whether or not the value you passed to your function greater_less_equal_5.
The idea is correct, it is but the problem is that: you've fixed the values of each conditional.

If I write print greater_less_equal_5(4) it will return 1 because 3 is greater than 1.
You code is just comparing whether 3 is greater than 1 or the other way around.

You are supposed to check if the value (stored in answer) is greater than 5:

if answer > 5

If is less than 5:

elif answer < 5

Or if it's equal to 5:

elif answer == 5

I'm based on your function name and info you gave about it.
It's a good idea to link it to the exercise you're having problems with, just so others can check what they're asking and what they've implemented.

Hope it helps you out! :slight_smile:


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