I got 101 problems but a switch ain't one Python


#1

https://www.codecademy.com/courses/learn-python/lessons/conditionals--control-flow/exercises/i-got--problems-but-a-switch-aint-one?

It keeps on saying It looks like your function output 0 instead of -1 when answer is 3. Make sure you filled in the if and elif statements correctly!. But I changed it and it still didn’t work.

I expect it to work well

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






#2

from the instructions:

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

i don’t see you answer?


#3

The console says it’s five but it doesn’t work


#4

we have 3 print statements:

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

and if we then look at the output:

1
1
1

they all produce 1, the first print statement 4 isn’t greater then 5, in fact, 4 is smaller then 5, so -1 should be returned when the function is called with argument value of 4, which is why you need to use answer in your comparison/conditions, this will be explained later


#5

Im having this exact same issue and haven’t been able to resolve it for a while now. Any luck?


#6

if you have a question, you can create a new (linked) topic rather then hijacking an existing topic which causes clutter


#7

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