17 - Review Functions - TypeError: 'str' object is not callable



I'm getting the following error - but everything looks right (I know we all say that)

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

What is this error - 'str' object not callable within the context of this function? I've reviewed on stack exchange but didn't see anything that really applied to this function.

def shut_down(s):
    if s == "yes"():
        return "Shutting down"

    elif s == "no"():
        return "Shut down aborted"
        return "Sorry"
s = raw_input("Do you want to shut down? Enter yes or no.").lower()
print shut_down(s)




this is a function call because of the parentheses, the error message tells you strings can't be function calls (are not callable)


This looks like a function call. Hence, str is not callable. Remove the ().


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