Printing and returning are completely different concepts.
print
is a function you call. Calling print
will immediately make your
program write out text for you to see. Use print
when you want to show a
value to a human.
return
is a keyword. When a return
statement is reached, Python will stop
the execution of the current function, sending a value out to where the
function was called. Use return
when you want to send a value from one point
in your code to another.
Using return
changes the flow of the program. Using print
does not.
The fastest way to learn programming is with lots of practice. Learn a programming concept, then write code to test your understanding and make it stick. Try our online interactive Python course today—it's free!