+ 4

return Vs print

What is the use of the return function? Is not just a more limited version of the print funtion? I feel like i can obtain the same results with print without anymore hassle. Am i missing anything?

2nd Sep 2016, 11:07 AM
Michele Romano
Michele Romano - avatar
5 Antworten
+ 4
return is use for take value after end function you can assing value like a = func() print is jsut display value or string but you can't assing them
2nd Sep 2016, 1:04 PM
beauty1234
+ 3
print outputs a string to console, it's information just for user. return is what a called function answers to what called it. in can be assigned to variable, given as argument to another function, printed (like print func()) etc.
2nd Sep 2016, 1:04 PM
Demeth
Demeth - avatar
+ 3
Print is an output into the console, while return ends a function with an ouput
8th Sep 2016, 1:45 PM
Nico
Nico - avatar
0
they different, the return statement is use to perform the following functions 1. to return a value from a method 2. to terminate a code snipet a method because any code after return statement in a method cannot be reach the print statement is use to output information to the screen for user to see
2nd Sep 2016, 1:56 PM
Lawal Abdulateef olawale
Lawal Abdulateef olawale - avatar
0
This is only in Python3. To promote and extend support for Higher Order Functions or Functional Programming.
12th Nov 2016, 12:25 PM
Saif Ali
Saif Ali - avatar