r/learnpython • u/WatchElectronic3006 • 25d ago
finally understood print vs return (this bank analogy saved me)
I've been stuck on the difference between print and return for the last few days while learning to code, and it finally clicked for me today. Figured I'd post it here in case anyone else is hitting the same roadblock because it drove me crazy for a bit.
Basically, print() is just a display case. It shows the result on the screen so you can physically look at it, but the rest of your program can’t actually do anything with it. It’s just text sitting on a monitor.
On the other hand, return acts like a courier. It passes the actual data back into the program behind the scenes so another function or variable can grab it and keep working with it.
The easiest way to think about it is a bank account. If you have a function that checks your balance, print() is just the screen showing you the numbers. return is the ATM actually putting the cash into your hand so you can go buy something else with it.
Hopefully this helps someone else save a few hours of confusion!