+ 2

What is difference between using return or print? Or can they kinda be used interchangeably?

18th Aug 2016, 6:12 PM
Michael Kolodziej
4 Answers
+ 7
return means you got an value and you can assign to a variable or constant or just forget it print means it will always print the result on the console(mostly use for debugging)
23rd Aug 2016, 10:42 AM
Nplus Chang
Nplus Chang - avatar
+ 4
Return obviously return some object (value, string, tuple ect.), which could be operated in the following code. Print just display some text on your screen. This helps you to see what happens "inside" your code.
31st Aug 2016, 9:59 PM
Aleksandr Budnik
Aleksandr Budnik - avatar
+ 1
in simple terms return as the name suggests returns from certain scope to another previous scope. more like you call a function it goes to function body perform tasks in that scope and returns back to the scope where it was called. now print is simply used to print some results in the console
16th Nov 2016, 1:20 AM
Nischal Aryal
Nischal Aryal - avatar
0
"return" is a keyword used to return execution back to the calling function, with or without a return value. "print" is a library function and not a keyword and is used to print out or display values and/or variables to some output window.
18th Nov 2016, 6:42 PM
Stephen Learmonth
Stephen Learmonth - avatar