Greater/less/equal to 5


#1

Continuing the discussion from Greater_less_equal_5:



Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: invalid syntax (python, line 2)


Replace this line with your code. 

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

you are not comparing 5 with anything?

remember that answer (the function parameter), contains the argument pass by the function call, so maybe you can use answer to compare with 5?


#3

Now what do I do?

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

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

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


#4

i said you should compare answer with 5 in the if and elif condition, not fixed number. Think about what answer contain, if you don't know print it:

def greater_less_equal_5(answer):
    print 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)

#5

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