17. Review:Function



Oops, try again. Did you create a function called shut_down?

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

I am unsure why I am getting the above error, surely def shut_down(s): is the function in question?


i would look at the error message in the output window, is there one? If not, add a function call at the end:

print shut_down("no")

now you can the interpreter error message in output window which is much more useful


Here are the errors I get when I add that:

Traceback (most recent call last):
File "python", line 9, in
File "python", line 2, in shut_down
TypeError: 'str' object is not callable

Line 9 is the new function call and line 2 is if s == "yes"():


why the () after "yes"? This means python is going to attempt a function call on a string, that won't work (str(ing) object not callable, as you can see in the error message)


Not sure why I did that but it was the only problem I had so thanks for the help.