In Python, commas create tuples; parentheses are commonly added to make the grouping clear. Use () for an empty tuple, (value,) for a one-item tuple, and comma-separated values for a tuple with multiple items. You can access tuple items by index, unpack them into variables, and choose a tuple when the grouped values should not be reassigned as items.
How do you declare a tuple?
A tuple is an ordered sequence whose item bindings cannot be reassigned. Commas are what make comma-separated values a tuple; parentheses are optional in many expressions but make the grouping easier to read.
point = (3, 5)
coordinates = 3, 5
empty = ()
singleton = (3,)
The comma is essential for a one-item tuple. (3) is the integer 3 inside grouping parentheses; (3,) is a tuple. Python’s tutorial and data model document these forms.
Tuples can contain values of different types, as well as other tuples:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
record = (42, "Ada", True)
nested = (point, (8, 13))
Create a tuple from an iterable
Use the built-in tuple() constructor to make a tuple from an iterable, preserving its iteration order. Calling tuple() without an argument creates an empty tuple.
letters = tuple(["a", "b", "c"])
empty = tuple()
See Python’s built-in tuple documentation for the constructor and tuple operations.
Rank #2
How do tuple packing and unpacking work?
Assigning comma-separated values packs them into a tuple. Assigning a sequence to a matching set of names unpacks its items:
point = 3, 5 # packing
x, y = point # unpacking
In ordinary unpacking, the number of target names must match the number of sequence items. A starred target collects any remaining items into a list:
first, *middle, last = (1, 2, 3, 4)
# first is 1; middle is [2, 3]; last is 4
Python’s sequence tutorial describes unpacking and multiple assignment, which combines packing and unpacking.
How do you read tuple values?
Tuples support sequence operations including indexing and slicing. Indexing starts at zero, so point[0] reads the first item in point; slicing selects a range of items and returns a tuple.
point = (3, 5)
first = point[0] # 3
both = point[0:2] # (3, 5)
What does tuple immutability mean?
You cannot replace, append, or remove tuple items in place. To represent a different sequence, construct a new tuple. The restriction applies to the tuple’s item bindings, not automatically to every object referenced by those items.
container = ([1, 2], "label")
container[0].append(3) # the contained list changes
# container[0] = [9] # TypeError: tuple item assignment is not supported
The list inside container remains mutable, even though the tuple cannot be made to point to a different first item. Python’s tutorial illustrates this distinction.
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
Should you use a tuple or a list?
Choose based on whether the sequence itself needs to change, rather than on a rule about the types of its contents.
| Need | Choose | Why |
|---|---|---|
| Represent a fixed group or record whose items should not be reassigned | Tuple | Tuple item bindings are immutable. |
| Add, remove, or replace entries in the sequence | List | Lists are mutable. |
| Use a compound sequence as a dictionary key or set member | Tuple, only if every item is hashable | A tuple containing an unhashable value, such as a list, cannot be hashed. |
Python’s documentation describes tuples as commonly heterogeneous and lists as commonly homogeneous, but that is a convention, not a requirement: a tuple can contain values of the same type, and a list can contain different types. The tutorial and built-in type documentation explain the distinction.
How do you annotate tuple types?
For a fixed pair containing an integer and a string, write tuple[int, str]. For a tuple with any number of integers, write tuple[int, ...].
person: tuple[int, str]
coordinates: tuple[int, ...]
For a tuple type with unpacked components, the typing specification describes starred tuple type syntax for Python 3.11 and newer; its compatibility form uses typing.Unpack. Check the typing specification for the syntax supported by your target Python version.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




