How to Teach the Difference Between print and return
In week five of our adult evening group, a learner called me over because her code had stopped working. Her function for calculating a tip was fine. She had tested it a dozen times and the right number appeared on screen every time.

In week five of our adult evening group, a learner called me over because her code had stopped working. Her function for calculating a tip was fine. She had tested it a dozen times and the right number appeared on screen every time. Then she tried to add the tip to the bill total and Python told her it could not multiply a NoneType by an integer, which to her read as a message about something she had never heard of.
She had written print(bill * 0.15) as the last line of the function instead of return bill * 0.15. Out of fourteen learners that evening, eleven had done the same thing in at least one function. None of them knew, because printing looks exactly like working. This is the single most reliable confusion I meet in a beginner Python course, and it is not a syntax problem. It is a problem with what the learner thinks a function is for.
Why print feels like the right answer to them
Think about what happens in the four weeks before functions arrive. Every exercise ends with something appearing on screen. That is the only feedback channel a beginner has. Correctness and visibility become the same idea, so a function that shows the answer has, from inside their model, done its job completely.
My maths teaching years made this worse before they made it better. I assumed the vocabulary would transfer, since every student has seen f(x) = 2x + 1 and knows that f(3) is 7. It turns out they know how to evaluate it on paper and have never had to care where the 7 went afterwards. On paper the 7 just sits there and you look at it. That is printing. Nothing in school maths teaches you that the 7 has to be handed somewhere.
So telling them the definition again does nothing. I tried that for two terms. What works is building a situation where printing visibly fails and the failure is their own code, not mine.
The demo that lands in six minutes
Write two functions on the projector, side by side, both obviously correct to a beginner's eye.
def tip_shown(bill): print(bill * 0.15)def tip_given(bill): return bill * 0.15
Call each one on its own first. tip_shown(40) puts 6.0 on screen. tip_given(40) also puts 6.0 on screen in the interactive shell, which is a trap worth naming out loud, because the shell echoes return values and that single behaviour hides the difference for weeks. I say this explicitly now: the shell is being helpful in a way that is lying to you.
Then ask the room to predict the output of total = tip_shown(40) followed by print(total). Hands go up for 6.0. The screen says 6.0 and then None, and the gap between those two lines is where the lesson lives. Let them sit in it for a moment before explaining.
Finish by asking for print(tip_shown(40) + 40). The traceback mentions NoneType, and now they have a reason to care what NoneType is, which is a far better time to introduce it than as a bullet point in week two.
What the learner sees versus what actually happens
| What they typed | What appears | What the function handed back | Why it misleads |
|---|---|---|---|
tip_shown(40) in the shell | 6.0 | None | Looks identical to a correct function |
tip_given(40) in the shell | 6.0 | 6.0 | The shell echoes the value, so both look the same |
tip_given(40) inside a script file | Nothing at all | 6.0 | Learner concludes the correct version is broken |
total = tip_shown(40) | 6.0 | None, stored in total | Printing happens, so they stop reading |
print(tip_shown(40) + 40) | 6.0 then a traceback | None | The error arrives on a line that looks innocent |
Row three is the one I would put on a poster. A learner who fixes her function correctly, runs the script, and sees no output at all will usually undo the fix. She has produced a better function and received a worse signal, which is a brutal thing to do to someone in week five. Warn them before they hit it.
The slogan everyone repeats does not do the work
Search for this and you get a sentence: print shows the value to a human, return gives the value back to the program. It is accurate. I used it for a long time and I now think handing it to a beginner is close to useless on its own.
The reason is that the slogan describes a distinction with no consequence attached. A learner who has never needed to pass a value anywhere has nothing in their experience that the second half of the sentence attaches to. They nod, write it in their notes, and produce the same bug on the next worksheet. I tracked this in a group of twelve: nine could state the rule correctly when asked, and seven of those nine still wrote print inside a function in the following week's task.
I will push back on the other common recommendation too, which is to introduce return on day one so the habit never forms. It sounds right and it costs more than it saves. Functions on day one means parameters, scope, call stack and the shell's echoing behaviour all land before anyone has written a loop. I have watched that approach sink two cohorts. The mistake is not that learners meet print first. The mistake is letting them meet functions in a context where printing still works.
Which leads to the actual fix: change the exercises, not the definitions.
Two exercises that make return the only option
The first is a chain. Ask for three functions where each one consumes what the previous one produced: a function that converts a price to cents, one that applies a discount, one that formats the result as a string for display. Specify that only the last line of the whole program may contain print. The constraint does the teaching, and it takes most groups about 25 minutes.
The second is a sort. Ask for a function that takes a list of club member names and returns the ones longer than five letters, then sort the result in the calling code. A printing version cannot be sorted, and the failure is immediate and obvious rather than a quiet wrong answer. This one also sets up list handling, so it earns its place twice.
Alongside both, I use a naming rule that has done more for my classes than any amount of explanation. Any function that prints must have a name starting with show_. Any function that returns gets a noun or a verb phrase. So show_receipt is allowed to print and total_with_tip is not. When a learner asks me why her code fails, my first question is now whether the function name promises a value or a display, and about half the time she spots the problem herself before I have finished the sentence.
Both exercises work better if the group has already done paper tracing, because they can follow a value from one function into another by hand. We covered that method in running code on paper with trace tables, and the vocabulary around storing a value is easier if assignment has been taught carefully, which is the argument in explaining variables without the box analogy.
What to expect afterwards
The confusion does not vanish in one session. In my groups it drops sharply for about two weeks, then reappears the first time someone writes a function with a loop inside it, because the urge to watch the loop work brings print back in. That reappearance is normal and I have stopped treating it as a failure of the lesson. I just ask what the function hands back, and the student usually answers correctly while looking slightly annoyed.
One limitation worth naming. My groups are adults and teenagers who can read a traceback with help. With younger learners coming from block based tools, the NoneType error is more frightening than instructive, and I would run the chained exercise without ever showing the traceback. More experienced mentors in our club disagree with me about that, and I do not have enough cohorts to claim I am right.
FAQ
Can a function print and return at the same time?
It can, and occasionally that is the clearest option. For beginners I ban it for a term, because a function that does both lets them keep the wrong model alive while their code happens to work. Once they can explain what the call hands back, the ban can be lifted.
Why does the shell show the value if I did not print it?
The interactive shell echoes the result of each expression you type, as a convenience. Scripts run from a file do not. Showing the same function in both places is the fastest way to make that difference concrete for a class.
Is a function with no return statement wrong?
Not at all. Plenty of useful functions exist to do something rather than produce something, such as writing to a file or drawing on screen. Python hands back None from those, which is correct behaviour and not an error. The problem is only a mismatch between what the name promises and what the function gives.
How much session time does this need?
Six to eight minutes for the demo, then 25 to 40 minutes for one of the exercises, so it fits comfortably inside a 90 minute meeting with time left for questions. I would not try to cover both exercises in one evening.
More in Teaching Code
Teaching Code
How to Teach Beginners to Read Python Documentation
I ran a small test at club last February because I was tired of a specific pattern.
Teaching Code
How to Train Volunteer Mentors for a Coding Club
Our club recruited nine volunteers in one term. Three were still turning up by week six.
Teaching Code
Trace Tables: Teaching Beginners to Run Code on Paper
A student shows me a loop that should add the numbers from 1 to 10 and prints 45 instead of 55.