Functions 17/19 (Review: Functions): Completely lost


Edit: I got a green box with a checkmark in it, but I have no idea how or why what I did was correct.

Step 1: First, def a function, shut_down, that takes one argument s. Don’t forget the parentheses or the colon!

No problem! I can do that. Easy. Next step:

Then, if the shut_down function receives an s equal to “yes”, it should return "Shutting down"

Okay what? If it “receives an s equal to “yes?”” What does that mean? I already defined the function with an argument of “s” - def shut_down(s) - under what circumstance would it not have an “s”? I know that I’m supposed to start with “if” but that’s as far as I can get. My best guess is:

if shut_down(s) == “yes”:
[indent]return “Shutting down”

or maybe

if s == “yes”:
[indent]return “Shutting down”

but that is 100% a guess; and if that is the correct next step, then I don’t know why and I haven’t learned anything.
Next step:

Alternatively, elif s is equal to “no”, then the function should return “Shutdown aborted”.

Still completely lost. My best guess is:

elif shut_down(s) == “no”:
[indent]return “Shutdown aborted”

but–again–100% guessing here, and if the little red box with an X in it turns into a checkmark, I won’t know why this wasn’t wrong.
Next step:

Finally, if shut_down gets anything other than those inputs, the function should return “Sorry”

Pretty sure it’s just

[indent]return “Sorry”

The hints aren’t helping me.

“Ensure your function outputs appear exactly as shown!”

What? Shown where? What does this even mean?

Also, ensure your function returns the above values rather than printing them.

Huh? When did we ever talk about the difference between returning and printing? I’m at the end of this unit and I keep waiting for it to tell me what “return” even means. I even Googled it, but couldn’t understand what people were saying it meant because the definition was all jargon. I’ve just been following the steps waiting to get it, but I still don’t. Before reading this hint in “Functions” exercise 17 of 19, I didn’t even know the two could be confused with one another.
It’s extremely frustrating to feel so lost and feel like I should be getting it.


It doesn’t say that, it says what value s may refer to

Your function probably shouldn’t be calling itself, or referring to itself at all for that matter.

Where it says what the result should be.

Right there if not earlier. Perhaps there’s an example showing how it’s used, and this points out that the result of the function is not presented by being printed. A return statement exits the current function call, optionally with a value being sent back, the result of the function call.


I think this could be expressed more clearly as “when the argument s is assigned the value ‘yes’”; i.e. if you called the following:


then the output from the function ought to be “Shutting down”.

Similarly to before, if we call the function shut_down and pass the value “no” to the argument “s”, the function should output “Shutdown aborted”.

In the instruction, where it’s telling you

it should return “Shutting down

they mean that your function should return exactly that string as output, not “Now shutting down” or “Shutdown In Progress” or something like that.

I don’t think the difference is ever explicitly explained on the Codecademy Python course before this point.

I think the simplest way I can explain the difference is that “printing” refers to writing something to the console, i.e.

print "Python rules!"

whereas “returning” refers to leaving the currently running block of code (e.g. a function), and returning to where you were before - possibly with one or more items of output along for the ride.

Essentially, they’re hinting that your function ought to have one or more return statements, but no print statements (though I would imagine that the code would still pass if you used print to check the output before returning it…)

Does that help make things a bit clearer? :smile:


This is extremely helpful. Reading it made me feel sane and like I understood the exercise. Thank you.


Glad I could help. :slight_smile:


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