I keep screwing up


I still don't necessarily understand the logic behind what is going on; so my code keeps screwing up. Please help me for the love of god so I can get some explanations behind Boolean operators and this whole if, elif and else thing.

I'm stuck here : https://www.codecademy.com/courses/python-beginner-BxUFN/3/4?curriculum_id=4f89dab3d788890003000096#

Here is my error message so far: 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 expected it to magically work or something - I'm not sure if I'm cut out to do A - Level computing... (even though I have not done Edexcel GCSE and I need to catch up...

Anyways, here is my code...

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

Thank you internet :blush:


from the instructions:

On line 2, fill in the if statement to check if answer is greater than 5

you compare x with 5, not answer


There should not be any input other than the parameter, answer.

If you wish to use x instead,

x = answer

Now you will have your argument.


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