A tuple is an ordered collection, just like a list, but immutable — once created, its contents can never be changed, added to, or removed. Tuples are written with parentheses (or often no brackets at all) and are commonly used for a fixed group of related values that shouldn't change, like coordinates or a database record.
#how it works
1
Create with parentheses
(item1, item2, ...) — or even without them, using just commas.
2
Access by index
t[0] works exactly like it does for a list.
3
Tuples cannot be modified
There's no append, remove, or item assignment — the contents are fixed for good.
4
A single-item tuple needs a trailing comma
(5,) is a tuple; (5) is just the integer 5 in parentheses.
5
Tuples unpack directly into variables
x, y = point assigns both in one line.
#example
point = (3, 4)
print(point[0])
x, y = point
print(x, y)
single = (5,)
print(type(single))
Output
3
3 4
<class 'tuple'>
1point[0] accesses the first item, exactly like a list.
2x, y = point unpacks the tuple directly into two separate variables in one line.
3single = (5,) needs the trailing comma — without it, (5) would just be the integer 5 in parentheses, not a tuple at all.
#use cases
Representing a fixed group of values that belong together, like (x, y) coordinates or an (r, g, b) color
Returning multiple values from a function, since Python packs them into a tuple automatically
Using as dictionary keys, since tuples are immutable and lists are not
Signaling to other developers that a collection isn't meant to change
Practice Python interview questions
Every Python lesson maps to the matching interview topic, with answers written for current Python versions.
Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses →Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free →Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books →