Need help with " I've got 99 problems but a switch ain't one"


#1

need serious help.
brain melting


#2

It's all flow control, IE a switch. Below is an example of how to use flow control.

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

#3

thanks
could you tell me what invalid syntax means


#4

@astropi

It means you are not speaking the language correctly. The error generally has all the information for you to fix the issue.


#5

thanks for the help
it was appreciated


#6

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

print greater_less_equal_5(4)
print greater_less_equal_5(5)

and it still is not working for me help?


#7

The commands worked for me.


#8

Did you indent it?
The indentation is necessary otherwise it won't work.


#9

Be sure that you are stating what is < or > 5. answer < or > 5 .


#10

Well put, thanks zeziba. You are one of the greats out there! :clap:


#11

This has been a giant help!


#12

Hello!

This thread helped me to solve my problems, but I don't understand why I can't put any number instead of "answer"?