Review: Functions


A error message keeps popping up and I don't know what to do.

"maximum recursion depth exceeded"
This is my code below:

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


look at this:

# function declaration with parameter s
def shut_down(s):
    print s

# function call with string argument
print shutdown("example")

see how the arguments gets copied into the function parameter? so all you need to do, is compare s with yes and no.

you call the function inside the function, this is called recursion. Sort of like an infinity loop, but then with functions


Thanks all sorted now