Functions coding errors


#1



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.

Cheers!


def shut_down(s):
    return s
if shut_down():
    s=yes
    return shutting down
elif shut_down():
    s=no
    return shutdown aborted
else:
    return sorry


#2

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:


#3

def shut_down(s):
return s
if shut_down():
s=='yes'
return "shutting down"
elif shut_down():
s=='no'
return "shutdown aborted"
else:
return "sorry"

I modified it, and it still shows errors.


#4

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)


#5

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:


#6

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