+ 15

What does the return statement in python do

21st Aug 2019, 10:07 PM
Viksta
Viksta - avatar
29 Answers
+ 22
It returns a value such that when the function is called, the value is returned.
21st Aug 2019, 10:16 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 13
In simple explanation return is used in python to exit or terminate a function and return a value. In example if you use def myfunction():   return 3+3   print("Hello, World!") print(myfunction()) We call the function myfunction() And you will notice that it only print the return value 6 and terminate there. It'll not print the remaining code after return.
22nd Aug 2019, 4:11 AM
Krishnanshu Dey
Krishnanshu Dey - avatar
+ 6
Frankly it does exactly what it does in any other programming language, which is exit a subroutine or a main program. it may or may not return a value which could be a number or a list of values or a string. ☀️☀️
22nd Aug 2019, 3:16 AM
Sanjay Kamath
Sanjay Kamath - avatar
+ 6
Even if you don't use "return" a None-Type object is returned by default.
22nd Aug 2019, 8:40 AM
Thoq!
Thoq! - avatar
+ 4
It assigns the current result to the function and terminates further iteration but does not print the result.
11th Jun 2022, 8:11 AM
Victor Torgbor Abla-Tyei
Victor Torgbor Abla-Tyei - avatar
+ 2
And returns program flow to the point just after where the function was called from.
21st Aug 2019, 10:53 PM
Sonic
Sonic - avatar
+ 2
Lets say that your code looks like this: def Hello(): x = print("hello") return x a = Hello() a print(a) a will be equal to "print("hello") basically it does what its say
5th Jul 2022, 10:30 AM
Bogyo - Leția Eduard
Bogyo - Leția Eduard - avatar
+ 2
This is a question that needs to be rephrased replacing "Python" with "ANY". It takes you out of the program like an EXIT condition.
15th Mar 2023, 11:31 AM
Sanjay Kamath
Sanjay Kamath - avatar
+ 1
It returns the valur of the function
23rd Aug 2019, 8:31 AM
Arunkumar
Arunkumar - avatar
0
Return statement give results that can store in variables
28th May 2021, 5:10 AM
Sandeep Kumar
Sandeep Kumar - avatar
0
It returns the value that you have given for that function and exits from that function.
10th Dec 2021, 11:07 AM
Sai Ganesh Darni
Sai Ganesh Darni - avatar
0
it returns value for future use. It can be accessed later other than that function.
14th Dec 2021, 5:04 AM
Păńkäź
Păńkäź - avatar
0
It returns the output of your function routine. Like you can check if your routine succeeded by returning a boolean (true or false) or return the output of some math
12th Feb 2022, 3:40 PM
Jeff Krol
Jeff Krol - avatar
0
The Python return statement is a special statement that you can use inside a function or method to send the function's result back to the caller. A return statement consists of the return keyword followed by an optional return value. The return value of a Python function can be any Python object.
5th May 2022, 10:08 PM
Lloyd Allen
Lloyd Allen - avatar
0
Returns values above it
21st Aug 2022, 11:08 PM
Kelvin
0
return the value of the function
14th Mar 2023, 7:21 PM
Maryam Khan
- 1
Basically when you write a function Def addTwoNums(a, b): return a + b print(addTwoNums(1, 2)) Result: 3 This is because when called the function and put in two parameters, the function will return the sum of the two, and then we print it to the screen which is also three so therefore, you have three
23rd Apr 2021, 1:42 PM
Quoc Hung Nguyen
Quoc Hung Nguyen - avatar
- 1
Return is as it's named, it will exist you from a function with or without value. The value could be anything. Like: def some_function(): return 3+2 print (some_function())
29th May 2021, 12:53 AM
Nilesh Kumar
Nilesh Kumar - avatar
- 1
A return statement ends the execution of the function call and "returns" the result, i.e. the value of the expression following the return keyword, to the caller.
13th Aug 2021, 10:47 AM
MSD (Milad Sedigh)
MSD (Milad Sedigh) - avatar
- 1
Return statement in python like other programming languages is use to return a defined value or command in a function when it's been called
20th Nov 2021, 4:54 PM
Godwin Eke Uma