Lesson 14 (conditionals % control flow)


This is my code.

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

What am I doing wrong here? This lesson is confusing me quite a bit.


What is your error message?

I'm assuming that it wants you to do something like

if answer>5:


elif answer<5:


@arizeto ,

(EDIT: @kyleaw replied with sage advice while I was composing my post. See the above.)

The function parameter is answer. For this exercise, the code within the greater_less_equal_5 function definition needs to compare the value of answer to 5, rather than compare a constant to 5.

However, you have conditional headers such as this within the function ...

if 6>5:

Instead of comparing 6 to 5, compare answer to 5. The elif condition needs to be modified similarly.


Thanks guys. I somehow missed the answer parameter and confused myself quite a bit.


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