Having problem in I Got 99 Problems, But a Switch Ain't One


#1

I have some trouble solving the question in I Got 99 Problems, But a Switch Ain't One

https://www.codecademy.com/courses/python-beginner-BxUFN/3/4?curriculum_id=4f89dab3d788890003000096#

This popped up when I run the code:
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!

But I think my code is correct.

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)

Can anybody help me? Thank you!


#2


And this is the whole page of my question.


#3

well, looking at this code:

if answer < 5:
   return 1

3 is smaller then 5, so the condition evaluates to true, 1 is returned. Seems your conditions aren't correct


#4

Thank you! I just reversed my code. It worked!