← back to unit
Medium
# basics functions
return vs. print
This trips up almost every beginner at some point: print() only shows something on the screen — it doesn't hand a value back to your code. return sends a value back so you can use it, but doesn't show anything by itself:
def printer():
print("I printed!")
def returner():
return "I returned!"
printer()
result = returner()
print(result)
prints:
I printed!
I returned!
Your turn: define show_message() that prints the text Just showing! (no return). Define give_message() that returns the text Just returning! (no print inside it). Call show_message(). Then call give_message(), store what it returns, and print that.
💡 need a hint?
pyb-func-return-vs-print.py
loading...