Python Programming · Foundations
Tuples
On this page 9 sections
In 30 seconds
A tuple An ordered Python sequence whose positions cannot be replaced, added, or removed after the tuple is created. Full entry → is an ordered Python sequence An ordered collection whose elements can be addressed by position and visited in order. Full entry → whose own positions cannot be changed after the tuple is created. Commas form a tuple; parentheses often make the grouping easier to read. For example, point = 4, 9 stores two values, and x, y = point assigns them to two names. A one-item tuple needs a comma: ('north',).
Why this matters
Tuples let a program keep a small, fixed arrangement of values together while still allowing normal sequence operations such as indexing, iteration, and unpacking. In coursework, they make it possible to represent items such as a coordinate or a record returned from a calculation without inventing a class first. Understanding the comma rule and immutability also prevents subtle bugs: a value that merely looks parenthesized is not necessarily a tuple.
The college version
A tuple is a sequence with fixed positions
Python documents tuples as immutable Not permitting changes to an object's own stored structure after creation. Full entry → sequences. A tuple holds zero or more object references in an order, so its elements have positions beginning at index 0. That makes familiar sequence operations meaningful: point[0] reads the first value, and a for loop can visit values in order. Immutability means the tuple does not support replacing, inserting, or deleting one of those positions after it is made. Thus point[0] = 7 raises TypeError when point is a tuple. This is a property of the tuple container, not a promise that every object reachable through it is immutable. A tuple can contain an object whose own state can change; the tuple still keeps the same reference at that position. For a foundations lesson, the useful rule is precise: you cannot assign to a tuple slot.
That rule also helps interpret error messages. Python is not saying that the expression 7 is forbidden or that the first position cannot be read. It is rejecting an operation that would replace the object reference stored at position 0. Reading point[0] remains valid, and constructing a separate tuple with another first value remains valid. Keeping read, construction, mutation, and assignment as distinct actions is a practical way to reason about code.
Immutability is not the same as making a name permanent. Python names can be rebound. After point = (4, 9), writing point = (7, 9) makes point refer to a different tuple; it does not edit the earlier tuple. This distinction matters when reading code. One operation tries to mutate an existing object's position and fails; the other changes what a name refers to and is ordinary assignment.
Commas make tuples; parentheses clarify grouping
A comma is the essential syntactic feature for a tuple display Comma-separated expressions written in source code to construct a tuple. Full entry →. These two statements make equivalent two-item tuples: point = 4, 9 and point = (4, 9). Parentheses are common because they make a display readable and remove ambiguity inside a larger expression, but parentheses alone are only grouping: (4) evaluates to the integer 4, not a tuple. The empty tuple is the special display ().
The one-item case exposes the rule most clearly. ('north') is a parenthesized string expression. ('north',) is a tuple containing one string. The trailing comma is therefore required for a singleton tuple A tuple containing exactly one item, written with a trailing comma such as (value,). Full entry →, whether or not parentheses are written: single = 'north', also works. The official tutorial calls out both the empty and one-item cases because their syntax differs from the usual multi-item pattern. Knowing this rule is more dependable than guessing from whether parentheses appear in printed output.
Packing and unpacking connect values and names
tuple packing Creating a tuple by grouping comma-separated expressions, as in pair = 4, 9. Full entry → is the act of placing comma-separated expressions together. In coordinates = 4, 9, the right-hand side evaluates to a two-item tuple and is bound to coordinates. sequence unpacking Assigning values from an ordered sequence to a matching pattern of targets, as in x, y = pair. Full entry → goes in the other direction: x, y = coordinates assigns the first item to x and the second to y. The pattern on the left has to match the number of values supplied in this basic form. A two-name target cannot unpack a three-item tuple, and Python raises ValueError rather than silently discarding a value.
The order is part of the meaning: in x, y = coordinates, the first target receives the first sequence item. Swapping the target names changes which name receives which value, even though the tuple itself stays unchanged. This makes unpacking concise, but programmers should choose target names that reflect each position's intended meaning.
Unpacking is useful because it gives meaningful names to a tuple's positions at the point where those names are needed. For example, row, column = (2, 5) makes later calculations easier to read than repeatedly using indexes. This lesson keeps unpacking focused on direct assignment. Function parameter collection and returned values are related language features, but they belong in their own lessons. Likewise, tuples can be compared with other collection types, but this lesson concentrates on tuple construction, fixed positions, and direct unpacking.

Eli explains
The same idea, in plain words
Explain it like I’m 10
Think of a tuple as a small row of numbered cubbies. You can look in cubby 0 or cubby 1, and you can tell Python to give each cubby's item a name. But after the row is built, you cannot swap out what is in one cubby. If you need a different row, make a new row and have your label point to it.
The comma is the signal that says, 'these are several cubbies together.' Parentheses help people see the row, but a single item inside parentheses is still just that item. The comma in ('north',) is what makes one cubby into a tuple.
Picture it like this
A tuple is like a sealed two-slot label on a museum display: it keeps a first and second fact together, and you can read either slot or copy both facts onto note cards.
Where the picture stops working
A real label cannot contain objects that later change, while a tuple can hold a reference to an object with its own changing state. Also, a tuple has language-defined operations, not physical slots.
Worked example
A mapping program receives a coordinate and wants separate names for its two positions. Run this Python 3 code:
point = 4, 9
x, y = point
print(point)
print(x, y)
single = 'north',
empty = ()
print(single, len(single))
print(empty, len(empty))It prints (4, 9), then 4 9, then ('north',) 1, and finally () 0. The comma packs 4 and 9 into a tuple; the left-side pattern unpacks those two positions into x and y. The comma after 'north' creates a one-item tuple. By contrast, ('north') would be a string. Trying point[0] = 7 raises TypeError, while point = (7, 9) simply rebinds point to a new tuple.
Key takeaway
Tuples are ordered, immutable sequences. Commas create them, including the required trailing comma for a singleton; unpacking can then assign their ordered values to separate names.
Quick check
3 questions here, of 5 in this lesson’s practice set. Answers stay hidden until you check.
Which expression creates a one-item tuple containing the string
After point = (4, 9), what does point = (7, 9) do?
What is printed by this code? pair = 3, 8; left, right = pair; print(right)
Study tools & related lessonsYou’ll learn to · Common mistakes · Easily confused · Key vocabulary · Related
You’ll learn to
- Define a tuple as an immutable ordered sequence in Python.
- Construct empty, singleton, and multi-item tuples using correct syntax.
- Explain why commas, rather than parentheses alone, determine tuple formation.
- Apply sequence unpacking to assign a tuple's values to names.
- Distinguish changing a tuple binding from changing an item inside a tuple.
Common mistakes
Writing
(value)and expecting a one-item tuple.Add a comma: write
(value,)orvalue,.Saying parentheses alone create every tuple.
Use the comma rule; parentheses mainly make grouping explicit, while
()is the empty-tuple form.Trying to replace a tuple item with an indexed assignment.
Create another tuple and rebind the name if a different tuple is needed.
Using a different number of assignment targets and tuple values in basic unpacking.
Match the target pattern to the number of sequence values, or use a deliberately taught starred pattern in a later context.
Easily confused
`('north')` vs. `('north',)`
The first is a grouped string expression; the second is a one-item tuple because it has a comma.
`point[0] = 7` vs. `point = (7, 9)`
The first attempts to change a tuple position and fails; the second rebinds a name to a different tuple.
tuple packing vs. sequence unpacking
Packing forms one tuple from comma-separated expressions; unpacking distributes a sequence's ordered values to targets.
Key vocabulary
- tuple
- An ordered Python sequence whose positions cannot be replaced, added, or removed after the tuple is created.
- immutable
- Not permitting changes to an object's own stored structure after creation.
- sequence
- An ordered collection whose elements can be addressed by position and visited in order.
- tuple display
- Comma-separated expressions written in source code to construct a tuple.
- singleton tuple
- A tuple containing exactly one item, written with a trailing comma such as
(value,). - tuple packing
- Creating a tuple by grouping comma-separated expressions, as in
pair = 4, 9. - sequence unpacking
- Assigning values from an ordered sequence to a matching pattern of targets, as in
x, y = pair. - rebinding
- Making a name refer to a different object through a new assignment.
Sources & references
- 5. Data Structures — The Python Standard Library Documentation — Python Software Foundation
- Built-in Types — Python 3 documentation — Python Software Foundation
- The Python Language Reference — 6. Expressions (Operator precedence) — 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.

