Python · Stage 5 – Grouping Data · Lesson 31 of 50

Tuples

Store an ordered group that should not be changed.

point = (4, 7)
Line-by-line explanation
  1. Round brackets create this tuple.
  2. The tuple contains two integers.
  3. point stores the pair.

Tuple indexing works like list indexing:

x = point[0]
Line-by-line explanation
  1. Index 0 selects the first item.
  2. x stores 4.