The dragon explains
return hands a value back
The dragon: Every function you've written so far printed its own output. return is different — it hands a value BACK, silently.
The dragon: def compute_damage(): return 10 — calling compute_damage() does NOT print 10. It gives you 10 back, to use however you want.
example.pyPython 3def compute_damage(): return 10
The dragon: That's why print() and return can look confusingly similar, but aren't. print() shows something. return HANDS SOMETHING BACK for your code to use next.
The dragon: deliver(value) is a new ability — it actually SENDS a value somewhere, using whatever a function returned.
example.pyPython 3deliver(compute_damage())The dragon: And calling a function is never a one-way trip — once it returns, your code keeps going with the very next line, same as always.
Quick check
Check your understanding
Say your answer out loud before reading the marked one. Every wrong option is a mistake real beginners make.
Question 1 of 2
def compute_damage(): return 10 — with NO print() anywhere inside it. Does calling compute_damage() show anything on its own?
question.pyPython 3def compute_damage(): return 10compute_damage()
- No — return hands the value back silently, it doesn't display itCorrect
- Yes — 10 prints automatically, since that's what got returned
Why: No — nothing shows. return only hands the value back; something else (print() or deliver()) has to actually show or use it.
Question 2 of 2
deliver(compute_damage()), then print("DONE") on the next line. Does "DONE" still print?
question.pyPython 3deliver(compute_damage())print("DONE")
- Yes — the function call finishes and your code carries on to the next lineCorrect
- No — calling compute_damage() jumps away and "DONE" never runs
Why: Yes, DONE still prints. A function call finishes and returns, then your code carries on with the next line — exactly like any other instruction.
In the game
What you'll practice
Three levels in the game: one guided first try with the shape of the answer already there, then two to solve on your own.
- 1
GuidedYour first try
def compute_damage(): return 10 — this ability hands back a number instead of printing anything itself. Deliver that returned value to the battle log with deliver(compute_damage()).
- +2
PracticeTwo more, on your own
This lesson is part of PRO.
PRO is a one-time $49.99 purchase, no subscription, and unlocks this whole topic along with everything else. Topics 1–3 are free, start to finish.
Unlock this lesson with PROStuck three times? The game offers the answer — unasked.