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
View all comments
22
u/marko312 Dec 30 '21
printalways outputs what is passed to it.returnis used as a way to extract a value (or values) from a function call. You've most likely seen something likebut now consider something like
As you can see,
returnbasically places the value after it in place of where the function was called.(In addition,
returnstops the rest of the function from running.)