To return a tuple in Python, list the values after return separated by commas. Python packs them into one tuple, and the caller can keep it whole or unpack it into variables:
def price_range(prices):
return min(prices), max(prices)
low, high = price_range([19.99, 4.50, 12.75])
Every output below came from scripts I ran on Python 3.12.5 in Command Prompt.
In this tutorial, we’ll cover plain tuple returns, unpacking, the error you get when the counts don’t match, named tuples, and building a tuple on the fly.
Return a tuple from a function with commas
It’s the comma that makes the tuple, not the parentheses. return a, b and return (a, b) give the same result. If return itself is new to you, start with the Python return statement guide.
def price_range(prices):
return min(prices), max(prices) # the commas build the tuple
result = price_range([19.99, 4.50, 12.75])
print(result, type(result).__name__)
low, high = price_range([19.99, 4.50, 12.75])
print(f"Low: ${low:.2f} High: ${high:.2f}")
Output:
(4.5, 19.99) tuple
Low: $4.50 High: $19.99

low and high.How do you unpack a returned tuple?
Put one variable per value on the left. Use *_ to skip the middle, or index the tuple when you only need one item. The tuple unpacking guide has more patterns.
def order_summary():
return "A-1042", "Chicago", 3, 89.97
order_id, city, items, total = order_summary()
print(order_id, city, items, f"${total:.2f}")
order_id, *_, total = order_summary() # keep only the first and last values
print(order_id, f"${total:.2f}")
print(order_summary()[1]) # or index the tuple directly
Output:
A-1042 Chicago 3 $89.97
A-1042 $89.97
Chicago
Fix “cannot unpack non-iterable NoneType” when returning a tuple
Unpacking fails when one code path returns something else. Here the lookup returns None when the customer isn’t found:
def find_customer(customers, name):
for c in customers:
if c[0] == name:
return c[0], c[1]
return None # bug: only one value on this path
customers = [("Emily", "Austin"), ("James", "Denver")]
name, city = find_customer(customers, "Emily")
print(name, city)
name, city = find_customer(customers, "Olivia")
Output:
Emily Austin
Traceback (most recent call last):
File "C:\pyguides\find_customer.py", line 10, in <module>
name, city = find_customer(customers, "Olivia")
^^^^^^^^^^
TypeError: cannot unpack non-iterable NoneType object

return None path and raises a TypeError.I return None, None on the not-found path so every path gives two values. Too many or too few values raise a ValueError instead. Annotating the shape with tuple type hints lets a type checker catch this early.
Return a named tuple for readable results
Positions like result[2] get hard to read. A typing.NamedTuple adds field names but still behaves like a tuple:
from typing import NamedTuple
class Sale(NamedTuple):
region: str
units: int
revenue: float
def best_region():
return Sale("Texas", 420, 12599.50)
s = best_region()
print(s)
print(s.region, s.units, f"${s.revenue:,.2f}")
region, units, revenue = s # still unpacks like a plain tuple
print(region, units)
Output:
Sale(region='Texas', units=420, revenue=12599.5)
Texas 420 $12,599.50
Texas 420

If you need mutable fields or defaults, compare the options in dataclass vs namedtuple in Python.
Build and return a tuple dynamically
Pass a generator to tuple() when the length isn’t fixed. For one item, add a trailing comma; the reasons are in creating a tuple with one element.
def even_squares(n) -> tuple[int, ...]:
return tuple(x * x for x in range(n) if x % 2 == 0)
print(even_squares(10))
def one_item():
return "Boston", # trailing comma = 1-item tuple
def not_a_tuple():
return ("Boston") # just a string in parentheses
print(one_item(), type(one_item()).__name__)
print(not_a_tuple(), type(not_a_tuple()).__name__)
Output:
(0, 4, 16, 36, 64)
('Boston',) tuple
Boston str

("Boston") comes back as a plain str; the trailing comma version is a real tuple.Tuple vs list vs dict: what should a function return?
| Return type | Use it when |
|---|---|
| Tuple | A small, fixed set of values the caller unpacks |
| NamedTuple | Fixed values that deserve field names |
| List | A variable number of items the caller may change |
| Dict or dataclass | Many fields, optional fields, or values you’ll update |
For the other options side by side, see returning multiple values from a function in Python.
Keep going with these tuple tutorials:
- Declare and use tuples in Python
- Pass a tuple to a function in Python
- Work with a tuple of tuples
- Iterate through tuples in Python
Frequently asked questions
How do I return a tuple in Python?
Separate the values with commas after return, for example return low, high.
Do I need parentheses to return a tuple?
No. The commas create the tuple. Parentheses are optional, except for an empty tuple ().
How do I return a tuple with one element?
Add a trailing comma: return "Boston",. Without it you return a plain value.
Why do I get “cannot unpack non-iterable NoneType object”?
Some path in the function returned None. Return the same number of values on every path, such as None, None.
Should I return a tuple or a dictionary?
Return a tuple for two or three fixed values; use a dict, NamedTuple or dataclass when there are many fields.
Where are tuples documented?
See Tuples and Sequences in the Python tutorial.

Bijay Kumar is a 13-time Microsoft MVP with more than 18 years in software development, and the founder of Python Guides and TSinfo Technologies. He started out building .NET and SharePoint solutions at HP, TCS and KPIT before moving into Python, machine learning and AI, and he also builds web apps with TypeScript and React. He writes the tutorials here himself, and every example is run before publishing so you see the real output. More about Bijay · Microsoft MVP profile · LinkedIn