Function error


My code is saying "Oops, try again. Your function failed on the message yes. It returned 'yes' when it should have returned 'Shutting down'"

I think i had follow the instruction properly. So i think it should return "Shutting down" when s = "yes" or return "Shutdwon aborted" when s="no" else it should return "Sorry"

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


You can do this:

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

The example code was just for reference, probably. :slight_smile:


As soon as your function started, 's' was returned, ending the function right then and there. Also, your if-statements are outside of function, which means that 's' should not be defined at all since it is the parameter of the function and can only be used inside the function.


Just change the shut_down on if elif and else to return. :slight_smile:


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