#17: review function


Replace this line with your code.


this code should not have worked, what is giving me a green check mark?

def shut_down(s):
if s == 'yes':
return "Shutting down"

elif s == 'no': 
    return "Shutdown aborted"

    return "Sorry"



Hi, @at_1965 ,

We would like to copy your code, exactly as it was when you submitted it, so we can test it. But for us to do so, all of the details need to be visible, including the indentation.

It is important to format code in its entirety when you post it. But part of your posted code is not formatted.

See How do I format code in my posts?, then either post your code again with proper formatting, or edit your original post.


There's a similar problem with my code too.

def shut_down(s) :
return s

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

the error i am getting is

File "python", line 5
SyntaxError: 'return' outside function

Please help with the code


hi @codemaster03299 could you please provide a link to your code because according to your code as you know python is very strict about indentation and if the function or the if condition are at the same indentation then python will execute the code as though the return statement is outside the if statement.

Inshort there is an indentation problem on line 5.
here check my code :slight_smile:

i am providing the link as posting the code here will create indentation problems.



Hey...ronit1710, thanks for looking into the problem. Python really is
strict about indentation, I have learnt that now. Though, I realised what
was the error yesterday only, I am really thankful for the help you
Hope we will interact in future as I delve into the depths of programming.


Most welcome @codemaster03299. Surely we will interact in future. Mark this
as the solution if u feel it appropriate. :grinning::grinning:


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


Here is my code :

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


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