Python Programming · Foundations

Return Values

Want it in plain words first? Jump to Eli explains — the same idea, no jargon.
On this page 9 sections
  1. In 30 seconds
  2. Why this matters
  3. The college version
  4. Eli explains
  5. Worked example
  6. Key takeaway
  7. Quick check
  8. Study tools
  9. Sources & references

In 30 seconds

A is the result a function sends back to the code that called it. In Python, return expression evaluates the expression, immediately ends that function call, and makes the result available to the . A bare return, or reaching the end of a function without return, produces None. Returning a value differs from printing it: returned data can be stored, combined, or tested by other code.

Why this matters

Return values give functions useful, composable outputs. A caller can assign a returned result, pass it into another function, or make a decision from it without tying the function to a screen or file. This separation makes small programs easier to test: call a function with known data and compare its returned result with the expected one. It also makes a function's contract clearer, because readers can identify the result it promises and every path that produces it.

The college version

A return statement completes a call

A function call is an expression: it runs the function body and then produces a result at the point where the call appeared. Python's return statement supplies that result. In return total * rate, Python evaluates total * rate, passes that value to the caller, and leaves the current function call immediately. Statements later in the same function body are not executed on that path. The caller can place the result in a name, use it in an arithmetic expression, pass it to another call, or simply ignore it.

The word immediately matters when reading code. A function can contain several return statements, often in different branches, but a particular call follows only one path. Once that path executes return, the call is over. This is useful for guard clauses: after detecting invalid input, a function may return an appropriate result rather than nesting the remaining work inside another else. It also means that a statement written after an unconditional return is unreachable during that call. An editor may flag such code, but Python's language rule is simpler: return transfers control back to the caller.

An expression, a bare return, and the end of a function

The language reference specifies two related cases. If a has an expression list, Python evaluates it; if it has no expression list, Python substitutes None. Falling off the end of a function body likewise gives the caller None. None is a real singleton object used here to signal that the function did not provide a meaningful computed result. It is not the number zero, the empty string, or an empty list, even though all of those can be false in a Boolean context. Test for it by identity when needed: result is None.

This default helps functions whose purpose is an action, such as a small function that prints a label or changes an object. It is also a frequent bug signal. Suppose discount(price) returns a reduced price only when price > 100 and then reaches the end otherwise. The high-price path returns a number; the other path returns None. If a caller adds that result to a number, Python raises a TypeError rather than silently inventing a price. A function that promises a numeric result should normally return a numeric result on every intended path, including an explicit unchanged value when that expresses the policy.

Return is not print

print sends a text representation to standard output and itself returns None. return transfers a value to the caller. Those effects can look similar in an interactive session because both may cause a number to appear nearby, but they support different designs. Consider def show_total(x, y): print(x + y). Calling it displays a total, but saved = show_total(2, 3) binds saved to None, not 5. In contrast, def total(x, y): return x + y lets the caller decide whether to print, format, compare, or reuse 5.

Separating computation from presentation is practical. A total function can be tested with an equality assertion without capturing screen output. A user-interface layer can choose a message and formatting suitable for its setting. This lesson does not prescribe that functions never print; programs need output. It identifies the interface question: is the function chiefly reporting data to its caller, producing an external effect, or intentionally doing both? A clear name and an explicit return policy reduce surprises for callers.

One result can hold structured data

A return statement is not restricted to a single numeric value. It can return any Python object, including a string, list, dictionary, or . Comma-separated expressions in a return statement form a tuple, so return low, high gives the caller one tuple object that can be unpacked with low, high = bounds(values). The important design question is not a mythic limit on the number of things a function can return; it is whether the returned object clearly communicates the function's result.

For an introductory function, a direct value often makes the contract obvious. For related values, a tuple or a named structure can make the relationship explicit. Avoid using an accidental mixture of shapes, such as returning an integer on one branch and a two-item tuple on another unless callers are deliberately designed to handle both. Likewise, avoid making callers infer success from a printed message. Choose a return type and ensure every normal path satisfies that contract. Parameters, argument matching, and local-name visibility are separate topics; here the concern is the value that travels outward after a call.

Eli, the EliExplains learning guide

Eli explains

The same idea, in plain words

Explain it like I’m 10

Imagine asking a library clerk to find a book. You give the clerk a request, and the clerk hands a book back across the desk. That book is like a return value: the person who asked can now read it, put it on a shelf, or give it to someone else. A function can do work and hand its answer back in the same way. return 5 means “this call is finished; here is 5.” If the clerk finishes without handing you anything, you have no book. Python represents that no-result outcome with None.

Picture it like this

A return value is an item a clerk hands back to the person who made a request; the caller decides what to do with the item.

Where the picture stops working

A function does not literally pass an object through space, and None is still a valid Python object rather than an empty hand. Printing is also unlike returning: it is more like the clerk announcing a title aloud, which does not give the requester a value to reuse in another calculation.

Worked example

This function applies a simple membership discount and returns a price on both possible paths:

def final_price(price, member):
    if member:
        return price * 0.9
    return price

member_price = final_price(80, True)
guest_price = final_price(80, False)
print(member_price, guest_price)

The first call takes the if path: 80 * 0.9 evaluates to 72.0, and return ends that call. The second call skips the if body and reaches return price, so it returns 80. Running this exact code with python3 prints 72.0 80. If the final return price were removed, the non-member call would reach the end of the function and return None, violating the function's intended all-cases price contract.

Key takeaway

A return statement is a function's outward handoff: it ends the current call and gives a value to the caller. Design functions so their intended paths return clear, consistent results, and do not confuse returning data with printing it.

Quick check

3 questions here, of 5 in this lesson’s practice set. Answers stay hidden until you check.

Question 1 of 3foundational

What does a Python function return when it reaches the end of its body without executing a return statement?

Choose an answer, then check it.
Question 2 of 3intermediate

What happens after this path executes return total * rate inside a function?

Choose an answer, then check it.
Question 3 of 3intermediate

What value is assigned to saved by this code? def show(x): print(x + 1) followed by saved = show(4)

Choose an answer, then check it.
Practice all 5

Keep learning

Ready to build on this? Continue to the next lesson.

Practice this lesson
Study tools & related lessonsYou’ll learn to · Common mistakes · Easily confused · Key vocabulary · Related

You’ll learn to

  • Define a return value and explain how a caller can use it.
  • Trace how return expression evaluates an expression and ends a function call.
  • Distinguish returning a value from printing a value.
  • Explain why a function with no value expression returns None in Python.
  • Analyze a conditional function to find a path that accidentally returns None.

Common mistakes

  • Using print(value) when later code needs the value.

    Return the value from the computation and let the caller decide whether to print it.

  • Assuming a function without return returns the last expression it calculated.

    Python returns None when execution reaches the end without a value expression.

  • Writing statements after an unconditional return and expecting them to execute.

    Move needed work before return or place it in a different reachable branch.

  • Returning a value in only one conditional branch when every call needs a result.

    Trace every intended path and return an appropriate value on each one.

Easily confused

return vs. print

Return gives a value to the caller for later use; print writes a representation to standard output and returns None.

`return value` vs. bare `return`

The first evaluates and supplies a value; the second ends the call and supplies None.

`None` vs. an empty collection

None signals no useful result, while an empty list or string is an existing value with no elements or characters.

Key vocabulary

return value
The value a function call provides to the code that invoked it after the function completes.
return statement
A statement that optionally evaluates an expression, ends the current function call, and supplies its result to the caller.
caller
The code that invokes a function and receives control again when that function call completes.
None
Python's singleton object used to represent the absence of a useful value; it is returned by a function that has no value expression to return.
bare return
A return statement with no expression, which ends the function call and returns None.
unreachable code
Statements that cannot run on a particular control-flow path, such as statements after an unconditional return in the same block.
function contract
The documented or implied agreement about a function's inputs, outputs, and observable behavior.
tuple
An ordered, immutable Python collection; comma-separated expressions returned together form a tuple.

Sources & references

  1. The Python Language Reference — Simple statements (assignment statements) — Python Software Foundation
  2. The Python Tutorial — 4. More Control Flow Tools (if Statements) — Python Software Foundation

EliExplains lessons are original prose written from the open, credible references above. See Copyright & Licensing.

Researched 2026-08-19

Educational content only. It is not medical, legal or professional advice. Found an error? Tell us.