To find the length of a tuple in Python, pass it to len(): len(("Austin", "TX", 78701)) returns 3. It counts the top-level items only, so a nested tuple counts as one item, and it works the same for empty and single-item tuples:
store = ("Austin", "TX", 78701, 18250.50)
len(store) # 4
Every result below was printed by Python 3.12.5, including the two TypeErrors that surprise people.
You’ll see len() on normal, empty and one-element tuples, why (5) has no length, counting items in nested tuples, len vs count(), named tuples and generators, and checking length before you unpack.
Find the length of a tuple with len()
len() reads a stored size, so it’s instant no matter how big the tuple is. Parentheses are optional; the commas make the tuple:
store = ("Austin", "TX", 78701, 18250.50)
print(len(store))
print(len(())) # empty tuple
print(len(("Denver",))) # one element needs the comma
coords = 30.27, -97.74 # parentheses are optional
print(len(coords), type(coords).__name__)
Output:
4
0
1
2 tuple

Checking for zero is the usual empty test; there’s more in checking if a tuple is empty in Python.
Why does len() fail on a one-element tuple?
Because it isn’t a tuple. Parentheses alone just group an expression, so ("Denver") is a string and (5) is an int:
single = ("Denver") # just a string in parentheses
print(type(single).__name__, len(single))
number = (5) # just an int
try:
len(number)
except TypeError as err:
print("TypeError:", err)
print(type((5,)).__name__, len((5,)))
Output:
str 6
TypeError: object of type 'int' has no len()
tuple 1

The trailing comma is what you need. It’s the most common tuple bug I see, and it’s covered in creating a tuple with one element.
Find the length of a nested tuple
len() doesn’t look inside inner tuples. To count everything, add up the inner lengths, or recurse when the nesting goes deeper:
regions = (("Austin", "Dallas", "Houston"), ("Denver",), ("Tampa", "Miami"))
print("top-level items:", len(regions))
print("cities in total:", sum(len(r) for r in regions))
print("lengths:", [len(r) for r in regions])
def total_items(t):
"""Count every non-tuple item at any depth."""
return sum(total_items(x) if isinstance(x, tuple) else 1 for x in t)
deep = ("TX", ("Austin", ("78701", "78702")), "CO")
print("len(deep):", len(deep), "| all items:", total_items(deep))
Output:
top-level items: 3
cities in total: 6
lengths: [3, 1, 2]
len(deep): 3 | all items: 5

sum(len(r) for r in regions) handles one level; the recursive function handles any depth. Looping over tuples like this is covered in iterating through tuples in Python.
len() vs count(), named tuples and generators
count(x) answers a different question: how many times one value appears. Named tuples work with len() like any tuple, but generators don’t:
from collections import namedtuple
ratings = (5, 4, 5, 3, 5, 4)
print("len:", len(ratings), "| count(5):", ratings.count(5), "| distinct:", len(set(ratings)))
Store = namedtuple("Store", ["city", "state", "revenue"])
s = Store("Austin", "TX", 18250.50)
print(len(s), s._fields)
prices = (19.99 for _ in range(3)) # a generator, not a tuple
try:
len(prices)
except TypeError as err:
print("TypeError:", err)
print(len(tuple(prices)))
Output:
len: 6 | count(5): 3 | distinct: 3
3 ('city', 'state', 'revenue')
TypeError: object of type 'generator' has no len()
3

Converting a generator with tuple() uses it up, so do it once and keep the result. Named tuples and their alternatives are compared in Python dataclass vs namedtuple.
Check a tuple’s length before unpacking or indexing
Rows from files and APIs don’t always have the fields you expect. Checking len() first turns a crash into a clear message:
def parse_row(row: tuple) -> str:
if len(row) != 3:
return f"skipped {row!r}: expected 3 fields, got {len(row)}"
city, state, total = row
return f"{city}, {state}: ${total:,.2f}"
rows = [("Austin", "TX", 1250.5), ("Denver", "CO"), ("Tampa", "FL", 980.25, "extra")]
for r in rows:
print(parse_row(r))
last = rows[0][len(rows[0]) - 1] # same as rows[0][-1]
print("last field:", last)
Output:
Austin, TX: $1,250.50
skipped ('Denver', 'CO'): expected 3 fields, got 2
skipped ('Tampa', 'FL', 980.25, 'extra'): expected 3 fields, got 4
last field: 1250.5
Without the check, the second row would raise a ValueError on unpacking. If you index past the end instead, you get the error explained in IndexError: tuple index out of range.
Tuple length quick reference
| Expression | Result | Why |
|---|---|---|
len(("A", "B", "C")) | 3 | Three items |
len(()) | 0 | Empty tuple |
len(("Denver",)) | 1 | The comma makes the tuple |
len(("Denver")) | 6 | It’s a string |
len(((1, 2), (3,))) | 2 | Only top-level items count |
len(x for x in t) | TypeError | Generators have no length |
Ready for more tuple practice? Try these:
- Unpack a tuple in Python
- Access tuple elements in Python
- Convert a tuple to a string in Python
- Sort a tuple in Python
Frequently asked questions
How do I find the length of a tuple in Python?
Use len(my_tuple). It returns the number of top-level items.
Why does len((5)) raise TypeError?
(5) is just the int 5. Write (5,) to make a one-element tuple.
Does len() count items inside nested tuples?
No. Use sum(len(t) for t in nested) for one level, or a recursive function for deeper nesting.
What’s the difference between len() and count() on a tuple?
len() counts all items; count(x) counts how often one value appears.
Can I get the length of a generator?
No. Convert it with tuple(gen) first, or count with sum(1 for _ in gen).
Where is len() documented?
See len() in the Python docs.

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