Skip to content
BENIBIX Learn

Tuple

Development🧩 Programming ConceptsData and Variables

Also known as Tuples, Tuple (Python)

A small, fixed group of values in order. It usually cannot be changed.

Think of it like

It is like a sealed egg box. The eggs stay in their spots and you cannot swap them.

Example

A map app stores a spot as (51.5, -0.1), the latitude and longitude of London.

Why it matters

A tuple says these values belong together and will not change. That guards against a slip that edits one by mistake.

Definition

A tuple is a small, fixed group of values kept in order. Once made, it usually cannot be changed. Each spot often means something, like the x and y of a point. Python writes a tuple with round brackets, like (3, 4). A function can return a tuple to hand back two or three values at once.

Example code

python
point = (3, 4)
x, y = point
print(x)
# 3
A tuple of two numbers, unpacked into x and y.
The third card is a tuple. Three values sit in fixed spots.

Common mistake

Using a tuple for a list that grows. Use a list or array when items will be added.

Key takeaways

  1. 1
    Fixed size. The number of items stays the same.
  2. 2
    Ordered spots. Each place can have a meaning.
  3. 3
    Usually unchangeable. Made once, then read.

Compare

Learn it properly