Return
In one line
The return statement sends a value back to the caller and ends the function. Without it, the function returns None.
In simple words
The return statement sends a value back to whoever called the function and immediately ends the function's execution. The returned value can be used by the caller.
A function can return any type: a number, string, list, dict, or even another function. You can return multiple values as a tuple: return a, b — the caller can unpack them: x, y = func().
If a function ends without hitting a return statement, or uses return without a value, it returns None. A function can have multiple return statements (e.g., in different branches of an if/else), but only one will execute.
Example
def add(a, b):
return a + b
def min_max(numbers):
return min(numbers), max(numbers) # returns a tuple
def greet(name):
print(f"Hello, {name}")
# no return -> returns None
result = add(3, 5)
print(result) # 8
lo, hi = min_max([4, 2, 8, 1])
print(lo, hi) # 1 8return sends a value back and ends the function. Multiple values are returned as a tuple.
Common confusions
Confused with: print
The difference: return sends a value back to the calling code for further use. print displays text on the screen but returns None. A returned value can be stored in a variable; a printed value cannot.
Related terms
Related Resources
Related Lessons
- Functions
Return values.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.