Skip to content

Tuple

In one line

A tuple is an ordered, immutable collection of items in Python, written as (1, 2, 3).

In simple words

A tuple is like a list that you cannot change. Once you create a tuple, its size and contents are fixed — you cannot add, remove, or reassign elements. Tuples are written with parentheses: (1, 2, 3).

Tuples are used for fixed records where immutability is a feature — coordinates (x, y), RGB color values (255, 128, 0), or database rows. Because they cannot change, they are hashable and can be used as dictionary keys, which lists cannot.

Tuples are slightly faster and use less memory than lists. When you have a collection that should never change, a tuple signals that intent more clearly than a list. A tuple with one element needs a trailing comma: (5,).

Example

python
point = (3, 4)
color = (255, 128, 0)

print(point[0])   # 3
print(len(color)) # 3

# Tuples are immutable — this raises an error:
# point[0] = 10  # TypeError

# Tuples can be unpacked
x, y = point
print(x, y)  # 3 4

Tuples support indexing and unpacking but cannot be modified after creation.

Common confusions

  • Confused with: list

    The difference: A tuple is immutable — it cannot be changed after creation. A list is mutable — you can add, remove, and reassign elements. Use tuples for fixed data, lists for data that changes.

Related terms

Related Resources

Related Lessons

Learn the fundamentals

Deepen your understanding with structured lessons on this topic.

View lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary