What is the simple basic explanation of what the return statement is, how to use it in Python?
And what is the difference between it and the print
state
I think a really simple answer might be useful here:
return
makes the value (a variable, often) available for use by the caller (for example, to be stored by a function that the function using return
is within). Without return
, your value or variable wouldn't be available for the caller to store/re-use.
print
prints to the screen, but does not make the value or variable available for use by the caller.
(Fully admitting that the more thorough answers are more accurate.)