This is my input


#1

this is my input

def greater_less_equal_5(answer):
if 5 < (answer) :
return 1
elif 5 > (answer):
return 0

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

this is what I get
Oops, try again. 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!


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

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

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


#3

So I messed up and put this:

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

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

Answers:

-1
0
1
None

Ironically, it accepted it and let me move forward. When you switch the < to >, and vice versa, its wrong, though that is the answer it is asking for. Maybe I missed something....


#4

I'm trying the same thing and Its giving me the same trouble. Everything running smooth except for this particular. What am I missing?


#5

Sorry I found the answer. Now I'm trynna understand it. Thanks


#6

HI @microrockstar42366 @decodinglife did you pass the Lesson ?
Are you asking why you pass it? if so..
just look well the instruction..

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

And you made it..

if 5 < (answer)

then they aske you..

2. On line 4, fill in the elif so that the function outputs -1 if answer is less than 5.

elif 5 > (answer):

you also made it so if you change it you will do another thing and not what the lesson aske you to do

Hope that could help tyou


#7

Hello @wizmarco I understand the instructions Clearly, but I don't understand how to understand it


#8

Exactly! This seems to be hanging out in space with no way to connect what I did to get past the exercise to what I am supposed to be learning. How are we to intuit 'answer' has any role in this? The instructions are unclear and the error message certainly does not help.


#9

it's just a if, elif and else statement in a functon

An example willl be

def great_than(num):
    if 5 > num: #if num is less than 5
        return "5 is great than num" 
    elif 5 < num:#or if num is great than 5
        return "num is great than 5"
    else: #otherwise
        return "none"

#here call the function
great_than(3)
great_than(6)
great_than(9)

#Output
5 is great than num
num is great than 5
num is great than 5

@digitalpro10909 that lesson introduce you the elif statement


#10