Review functions


#1



I have been at this for far too long... help please

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


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


how can I get it to reyurn shutting down?


def shut_down (s):
    return s
    if s=='Yes':
        return "shuting down"
    elif s=='no':
        return "shutdown aborted"
    else: 
        return "Sorry"


#2

Get rid of your return s statement after def shut_down (s): the example in this lesson is a little misleading


#3

a function ends the moment a return keyword is reached, in your case the first line of the function:

return s

so your function only reach the first line, then exits because a return keyword is reached, the rest of your function never gets executed
also, string comparison is case-sensitive, so Yes might need to be yes


#4

I missed where it explained that. thanks.
I have deleted it and change Yes to yes. still gives me this error.
Oops, try again. Your function failed on the message yes. It returned 'Shuting down' when it should have returned 'Shutting down'

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

#5

Fix the spelling error in "Shuting down" to "Shutting down"


#6

another important thing (like @bibleman13 points out) is that strings returned/printed often need to be an exact match, Shutting is with double t


#7

thanks!
I can't believe that was the error!!!!
I am going to have to check my spelling better.
thanks


#8

Yeah I do that alll the time just ask @stetim94 and the other moderators Hope your other coding goes well!


#9

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