Functions: What is wrong with my code?


Traceback (most recent call last):
File "python", line 4, in
NameError: name 's' is not defined

I don't know what is wrong with my code.:thinking::thinking::thinking:

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


a function ends the moment a return keyword is reached, which is currently here:

return (s)

about the example:
Again, the example code above is just there for your reference!

in your case, you want to nest if/elif and else inside the function since you want to do comparison on s (the function parameter)

besides, your function should return specific strings.

Your function is different from the example. The example is just to show how certain syntax is, you still have to build this program


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