Can anybody solve this?


i m getting this error every time i submit the code.

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

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


What is the purpose of the first return statement? All that will do is return the variable s and stop executing the rest of the code.

Also, elif statements should be explicit (i.e. elif s == "no":)


hello nedwards,
i have tried the code by removing return s on second line, but still i was getting error saying have you created a function called shut_down()


Can you post the full code of what you have now?


yes for sure i have shared a code which i have been trying since 1hr, and i have shared the link also so that everybody can see the error.


I meant the revised code (without the first return statement), can you post all of that?


see the error


That's just a link to the exercise - which contains my code, not yours.

Can you post your revised code here?


Try this code on your python compiler and see what happened.

code starts here

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

end of code


Okay, the error message is technically wrong, but what's causing your code to fail is your elif no: line.

Conditionals should always be explicit, and by that I mean the following:

if s == "yes" or s == "Yes" <-- explicit

if s == "yes" or "Yes" <-- implicit, because it's implying that it should be checking if s == "Yes", rather than explicitly saying so. There are further reasons why this wouldn't work, but I won't go into them now.

So your elif statement needs to explicitly check if s == "no".

If you fix that (and properly capitalise "Sorry" on your last return line), your code should pass.


ok thnks bro for helping...!!
have a good day..!!


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