99 Problems


#1

I have looked at all of the other threads of people stuck on this lesson and still don't get it. This is what I have:
def greater_less_equal_5(answer):
if 6 > 5:
return 1
elif 6 < 5:
return -1
else:
return 0

print greater_less_equal_5(4)
print greater_less_equal_5(5)
print greater_less_equal_5(6)

But it says:
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!

I really don't understand what else I am supposed to do or what they mean when they say answer is 3. Please help!


#2

Try to compare answer with 5.


#3

Literally no help at all. Any further advise?


#4

def greater_less_equal_5(answer):

what's the point to take answer as parameter? you passed arguments for it but did you use it in your function?

it means when you pass 3 as argument your function output should be -1.

here you passed 4,5,6 as argument

print greater_less_equal_5(4)
print greater_less_equal_5(5)
print greater_less_equal_5(6)

#5

But why? Function has one parameter so this parameter should be compared with 5.


#6

You are trying to find how the variable "answer" fits into the inequality when "answer" is defined by your line 1 of code. Right now your code assumes that answer is always equal to 6 instead of the defined number. Therefore replacing 6 with "answer" will yield proper code. It says in your error message that when "answer" was defined as 3 your code output the wrong number, as "answer" was not a part of the inequality it was discarded by the code and the first true output will be printed, the number 1 as your first inequality was true. I hope this helps and best of luck!! :slight_smile:


#7

Find the solution yet? I'm still stuck on it too..


#8

What it's looking for is that (answer) is greater, less or equal to 5. Here is what i came up with.

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)


#9

Thanks everyone! I get it now. The answer was literally answer.


#12