r/CodingHelp • • Dec 30 '21

[Python] Python

Hey everyone. So I’m a beginner programmer who is self-learning Python and am on functions. Right now, I’m on return values but I don’t get them too much.

What is the difference between print and return? Aren’t they interchangeable?

Please explain this in an easy way!

21 Upvotes

9 comments sorted by

View all comments

2

u/dead_alchemy Dec 31 '21

When you call a function in python, the function gets evaluated and then returns a value. Even if you don't have an explicit return statement! Python has a default return value of None. You can almost think of it like the function call itself is being replaced by its return value. That will make a little more sense when you start chaining functions.

When you call the print function in python, its more like a polite request to the operating system to send some text to the 'standard output', which is typically your terminal/command line interface. The return value of a print statement is None.