Tuples: Ordered and Fixed
Scenario: A coordinate or database row should travel as one group without accidental edits.
New words, in plain English
- Tuple - an ordered, immutable collection
- Immutable - not changeable after creation
- Unpacking - assigning collection items to several names
Tuples normally use parentheses. A one-item tuple needs a comma. Unpacking makes structured values readable and a star can collect the remainder.
Analogy: A Python program is like a clear set of instructions for a careful helper: names label things, indentation groups steps, and errors explain where the helper became confused.
A small, real example
record = ("api", 443, True)
service, port, healthy = record
first, *rest = record
print(service, rest)
Tip: Choose a tuple for a fixed record and a list for a collection expected to grow or change.
Goal: Practice this idea in the py-list-basics challenge at/labs/python. Fix the broken program, run it yourself, then usecheckto prove the real end state.