Function review shut_down error


#1


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

I keep getting this error message: Oops, try again. Your function failed on the message yes. It returned 'yes' when it should have returned 'Shutting down'

Any help?


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


#2

The moment a return keyword is reached, something is returned, and the function ends. Take a look what happens on the first line of your function.

The rest of your function never gets executed


#5

Hi,

I am busy with Functions in Python and I am not sure why this code will not execute - please help:

def shut_down(s):

if (s == "Yes"):
    return "Shutting down"
elif (s == "No"):
    return "Shut down aborted"
else:
    return "Sorry"

shut_down("Yes")

I keep getting this message "Oops, try again. Your function failed on the message yes. It returned 'Sorry' when it should have returned 'Shutting down'"

Thank you


#6

Actually never mind.

The reason is that the program was looking for a small "y" in yes and that shutdown was one word.

Thanks