+ 5
What exactly is the return function ?
I wanna say_ How is return function different from print function ?
11 Answers
+ 4
M Umer
print displays the content to the console, return returns the value to a variable so you can use the value it just returned later in the program. in other words. print is just to print and return is to return a value.
+ 8
here's a code example to Jan's explination:
https://code.sololearn.com/cpGThocHw9cA/?ref=app
+ 7
each function is a return function. By default it returns None.
If you want another value u need a return statement.
Besides returning sth. functions can do other stuff:
printing, saving files... whatever.
+ 2
Great explanation đ
+ 2
For example you can make a deal with return
+ 1
Thank You_ but what can we do else with return, for example..
+ 1
The return statement is NOT a function. It goes inside one at the end.
As of Python 3, print IS a function.
This question is harder to answer because the SoloLearn interpreter basically uses input() like function parameters for the whole program, and it uses print() like a return statement for the whole program. In normal Python (ie on a PC), these functions display text on a console as they are called, and the input() function waits for the user to enter something before continuing, which it then returns as a string.
In short, return is a statement that goes inside functions when you want them to spit something out when theyâre done. Print is just for showing some output to the user and cannot give output to the rest of the program. Print() and input() are the program to user communicator functions, return and âparametersâ are the inner function program scope to outer program scope communicator⌠statement/format thigies.
- 2
int k=10;
k= k++;
System.out.printl(k);
Output in Java ??