Lesson 11 / 47

Tuples

Ordered and immutable — great for fixed groups of values.

Immutable by design

A tuple looks like a list but can't be changed after creation. Use it for data that shouldn't move.

point = (10, 20)
name, age = ("Ada", 36)   # unpacking
print(point[0])           # 10
# point[0] = 99           # TypeError

The trailing comma trap

A one-item tuple needs a trailing comma: single = (5,) — without it, (5) is just the int 5.