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


#1



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


It says there's a syntax error, but I've done what other users have said to do.


def greater_less_equal_5(answer):
    if  > 5 :
        return 1
    elif < 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

if :bulb: > 5 :
return 1
elif :bulb:< 5:
return -1
else:
return 0


#3

I tried doing this

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

yet i still get this error: "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!"

anyone help


#4

did you happen to try yilgul's suggestion? you have a comparision with only one arg. if what is greater than 5 or less than 5?:wink:


#5

im so dumb why am i even passionate about learning to program xd


#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)


#7

I know the feeling dude


#8

@therobinhood @jamescoderchamp Don't get discouraged so easily. Nothing is easy to achieve. As for @lordruhland , you never use the parameter "answer" in you actual code. You code needs to be like this:

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)

Hope that helps! :slight_smile: Let me know if you still don't understand.

-- @chipjumper36731


#9

Thank you ! :slight_smile:


#10

You're welcome! :slight_smile:


#11

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