I don't know what I'm doing wrong


Is there anything wrong with this?

Returning yes instead of shut down


def shut_down(s):

if shut_down("yes"):
    return "Shutting Down"
elif s("no"):
    return "Shutdown Aborted"
    return "Sorry"

I'm Getting this error:
Oops, try again. Your shut_down function threw the following error: maximum recursion depth exceeded


You call the function with the value s.
Then in the first if you will again call shutdown with the value "yes"
Then the methods starts again with s = "yes" -> First if statement
There you again call shutdown("yes").

This will repeat. Calling a the method of the method you are currently in is called recursion, mentioned in the error messege.

The if statement should check if s is equal to "yes" no need to call shut_down

Hope you understand :smile:
I know that i'm not that good at explaining. Tell me if you understood it or ask me what you didn't understand.

Edit: here's someone with the same question and another reply:


Thank You for your help, but I still cant get it. I'm not sure if I'm doing it wrong but here it is:
def shut_down(s):

if shut_down:"yes"
return "Shutting Down"
elif s:"no"
return "Shutdown Aborted"
return "Sorry"

And this is the error message...

Oops, try again. Your code looks a bit off. Feel free to peek back at earlier exercises if you need a refresher! Your code threw the following error: unexpected indent (python, line 4)


It should be like this
def shut_down(s):
if s =="yes":
return "Shutting Down"
elif s == "no":
return "Shutdown Aborted"
return "Sorry"

Thank You


def distance_from_zero(thing):
if type(thing) == int or type(thing) == float:
return abs(thing)
return "nope"


Cheers mate! I passed it! I corrected some mistakes, and passed it!