Functions coding errors


I just listed my codes here.

Maybe I just forgot what I have practiced in the previous lessons.

I don't know what errors are there in my code.


def shut_down(s):
    return s
if shut_down():
    return shutting down
elif shut_down():
    return shutdown aborted
    return sorry


That's fine.

I'll show you with one and then you should finish up the others. After the function definition, follow up with the conditions.

def shut_down(s): #function definition
    if s == 'yes': # the double equal to mean to check for the value if it's "yes"
        return "Shutting down" #Your return statement, which should be a string in quotes.

You should kindly watch out for your indentation and keep it in the right block.

I hope this helps! :wink:


def shut_down(s):
return s
if shut_down():
return "shutting down"
elif shut_down():
return "shutdown aborted"
return "sorry"

I modified it, and it still shows errors.


Please take the time to ensure that your code is formatted properly so that it can be executed without having to be "fixed" first (extra work, and the other person would have to guess what it's supposed to be)


Okay! It's good you highly regard the above comment before mine.

Now, returning the function immediately after declaring the function isn't good for this task. Let the conditions you set run, and return the string statements. So, remove:

Also, ensure right tab spaces.

By the way, the string statements start with capital letters (Upper cases).

return "Shutting down"
return 'Shutdown aborted'
return 'Sorry'

Let me know if this resolves. :wink:


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