+ 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?
5 Respuestas
+ 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
+ 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.
+ 3
Print is an output into the console, while return ends a function with an ouput
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
0
This is only in Python3.
To promote and extend support for Higher Order Functions or Functional Programming.