Review functions


#1



https://www.codecademy.com/en/courses/python-beginner-c7VZg/4/1?curriculum_id=4f89dab3d788890003000096#


Oops, try again. Your function failed on the message yes. It returned 'yes' when it should have returned 'Shutting down'


My code is not running correctly


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


#2

a function ends the moment a return keyword is reached


#3

so do i need a shut_down(yes) function at the end?


#4

where is a return keyword is reached? there the function ends, other words here:

return s

and this:

return shut_down(s)

i wouldn't do, calling a function inside a function causes recursion (sort of like infinity loop)


#5

but taking that out and having this still doesn't work

def shut_down(s):
return s

if s == "yes":
    print "Shutting down"
elif s == "no":
    print "Shutdown aborted"
else:
    print "Sorry"

#6

your function still ends really quickly? see where a return keyword is reached, that is where the function ends, after a return keyword the rest of the function doesn't execute


#7

don't worry, worked it out


#8