Tuples
A tuple is an ordered group that cannot change. Use it for fixed records such as a coordinate pair.
Syntax
point = (x, y)x, y = point
- A one-item tuple needs a trailing comma: (1,).
Example
point = (3, 4) x, y = point print(x) print(y)
Output:
3 4
Common mistakes
- Assigning to point[0] is a TypeError. Build a new tuple instead.