17/19 return outside function

Hi,
This is the code that I put in

def shut_down(s): 
    return message
    
if s == "yes":
    return "Shutting down"
elif s == "no":
    return "Shutdown aborted"
else:
    return "Sorry"

And this is the problem:
File “python”, line 5
SyntaxError: ‘return’ outside function

I don’t know how to fix it. Any advice?

def shut_down(s):
    if s == "yes":
        return "Shutting down"
    elif s == "no":
        return "Shutdown aborted"
    else:
        return "Sorry"

this is right

2 Likes

I inserted

def shut_down(s):

if s == “yes”:
return “Shutting down”
elif s == “no”:
return “Shutdown aborted”
else:
return “sorry”

but it doesnt work, it shows the message:

File “python”, line 3
if s == “yes”:
^
IndentationError: expected an indented block

You need indentation like how franzisak said

def shut_down(s):
    if s == "yes":
        return "Shutting down"
    elif s == "no":
        return "Shutdown aborted"
    else:
        return "Sorry"
2 Likes

i couldn’t seem to get mine to work either, but it does when i use yours - thanks ryebread4

1 Like

Funny, had the exact same code as the ones above… I only had the s == “Yes”, changed it to “yes” (lower case “y”) and it finally worked… anyone know why that is?

as per instructions its given ‘yes’.
it will not work if we dont type char according to instructions.

I fixed mine

1 Like

The problem is the function def and the spaces after it.
What netninja69513 make was define the variable of shut_down(s), that is made by the spaces.

Why did it say that I had exceed the maximum recursion depth when I wrote down that shut_down(s)==“yes”?

whenever i try this part, it always says "did you make a function called " shutdown

I don’t know what to make of this. please help

i realized i was doing something very stupid in that i made shutdown two separate words like “shut down” and so the program wasn’t working but the way that franzisak said to do it works fine!

1 Like

thanks franzisak…indeed it’s a legit solution

1 Like