17. function review


#1

I tried to do it the same way you instructed and the error just changed

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

print shut_down

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


Errors in 17.Review:Function
#2

here:

s = "No"

you overwrite your function paramater s, why?

"no" should also be all lowercase letters

finally, here:

shut_down("No")

print shut_down

why are this two lines? You call your function twice, but the second time without parentheses so this will give your function object as output


#4

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