To unpack a tuple in Python, write one variable per item before the equals sign: a, b, c = my_tuple. When the counts don’t match, add a starred name such as *rest to collect the extra items:
order_id, customer, total = ("A-1027", "Megan Bowen", 249.99)
first, *rest = (1, 2, 3, 4) # first = 1, rest = [2, 3, 4]
Sample orders, US cities and prices drive the examples, and I ran each one on Python 3.12.5.
In this tutorial, we’ll cover starred names, skipped values, loops, nested tuples, function results and unpacking errors.
Unpack a tuple into variables
The left side needs exactly as many names as the tuple has items:
order = ("A-1027", "Megan Bowen", 249.99)
order_id, customer, total = order # one variable per item
print(order_id, customer, f"${total:.2f}")
city, state = "Austin", "TX" # parentheses are optional
print(city, state)
Output:
A-1027 Megan Bowen $249.99
Austin TX

I find this much easier to read than order[0] and order[2]. For index access, see accessing tuple elements in Python.
Collect the remaining tuple items with starred unpacking
A starred name grabs whatever the other names don’t. You can put it first, last or in the middle, but only once per assignment:
monthly_sales = (1200.50, 980.25, 1430.00, 1105.75, 1620.40)
first, *middle, last = monthly_sales
print("first: ", first)
print("middle:", middle) # always a list
print("last: ", last)
head, *rest = ("Q1",)
print(head, rest) # nothing left over -> []
Output:
first: 1200.5
middle: [980.25, 1430.0, 1105.75]
last: 1620.4
Q1 []

You get a list in middle, not a tuple. The same syntax works on lists, as shown in unpacking a list in Python. To cut a tuple into fixed pieces instead, see splitting a tuple in Python.
Skip tuple values you don’t need with an underscore
By convention, _ names a value you’re throwing away:
employee = ("E-204", "Alex Wilber", "Seattle", "WA", "2026-03-16")
emp_id, name, _, _, start = employee
print(name, "started on", start)
Output:
Alex Wilber started on 2026-03-16
Because _ is an ordinary variable, it keeps the last value assigned to it. That’s fine for throwaway data, but don’t read it later.
Unpack tuples in a for loop
You’ll unpack tuples most often in loops, where the loop header splits each item:
cities = [("Denver", "CO", 715_522), ("Boston", "MA", 650_706), ("Miami", "FL", 449_514)]
for city, state, pop in cities:
print(f"{city}, {state}: {pop:,}")
prices = {"coffee": 4.50, "bagel": 3.25}
for item, price in prices.items():
print(f"{item}: ${price:.2f}")
for rank, (city, state, _) in enumerate(cities, start=1):
print(rank, city, state)
Output:
Denver, CO: 715,522
Boston, MA: 650,706
Miami, FL: 449,514
coffee: $4.50
bagel: $3.25
1 Denver CO
2 Boston MA
3 Miami FL

dict.items() yields (key, value) tuples, so converting a dictionary to a list of tuples gives you the same shape. More loop options are in iterating through tuples in Python.
With enumerate(), wrap the tuple in parentheses: rank, (city, state, _). The enumerate() guide explains the counter.
Unpack nested tuples
Mirror the structure on the left side. Each inner tuple gets its own pair of parentheses:
store = ("Store 12", ("Chicago", "IL"), (41.88, -87.63))
name, (city, state), (lat, lon) = store
print(name, "-", city, state)
print("lat/lon:", lat, lon)
Output:
Store 12 - Chicago IL
lat/lon: 41.88 -87.63
For deeper nesting, I’d unpack in steps. Working with a tuple of tuples shows more layouts.
Unpack a tuple returned from a function
A function that returns several values really returns one tuple. Unpack it into names, swap variables, or spread a tuple into arguments with *:
def price_stats(prices):
return min(prices), max(prices), round(sum(prices) / len(prices), 2)
low, high, avg = price_stats((19.99, 24.50, 18.75, 30.00))
print(f"low ${low:.2f} high ${high:.2f} avg ${avg:.2f}")
a, b = 10, 25
a, b = b, a # swap without a temp variable
print(a, b)
def ship(city, state, zip_code):
return f"{city}, {state} {zip_code}"
address = ("Portland", "OR", "97201")
print(ship(*address)) # * spreads the tuple into arguments
Output:
low $18.75 high $30.00 avg $23.31
25 10
Portland, OR 97201
Returning tuples is covered in returning a tuple in Python, and the * call syntax in passing a tuple to a function.
The swap works because Python packs the right side into a tuple first. For other ways, see swapping two numbers in Python.
Why does tuple unpacking raise ValueError?
Plain unpacking fails when the number of names and items differ. These are the four errors you’ll see most:
point = (3, 4, 5)
try:
x, y = point
except ValueError as err:
print("ValueError:", err)
try:
x, y, z, w = point
except ValueError as err:
print("ValueError:", err)
try:
a, b = 42
except TypeError as err:
print("TypeError:", err)
try:
compile("*a, *b = point", "<demo>", "exec")
except SyntaxError as err:
print("SyntaxError:", err.msg)
Output:
ValueError: too many values to unpack (expected 2)
ValueError: not enough values to unpack (expected 4, got 3)
TypeError: cannot unpack non-iterable int object
SyntaxError: multiple starred expressions in assignment

You can usually fix it with a starred name, or check len() first when your tuple comes from outside data.
Keep going with tuples through these related tutorials:
- Print a tuple in Python
- Declare and use tuples in Python
- Concatenate tuples in Python
- Python dataclass vs namedtuple
Frequently asked questions
How do you unpack a tuple in Python?
Assign it to one variable per item, for example a, b, c = (1, 2, 3).
What does the asterisk do in tuple unpacking?
A starred name like *rest collects the leftover items into a list. Only one starred name is allowed per assignment.
How do I ignore values when unpacking a tuple?
Use _ for one value and *_ for several, for example name, *_ = row.
Why do I get ‘too many values to unpack’?
The tuple has more items than names. Add names or a starred name for the extras.
Can I unpack a tuple directly into function arguments?
Yes. f(*my_tuple) passes each item as its own argument.
Where is tuple unpacking 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