Skip to content
BENIBIX Learn

Array

Development🧩 Programming ConceptsData and Variables

Also known as List

A row of values kept together under one name. Each sits in a numbered spot.

Think of it like

Think of it like an egg box. Each egg has its own spot, and the spots are in a row.

Example

A to-do app keeps Lucy's tasks in an array. Item 0 is buy milk, item 1 is call Jack.

Why it matters

Programs rarely deal with just one thing. Lists of users, songs and orders are all arrays.

Definition

An array is one value that holds many values in a row. Each item sits in a numbered spot, and the count starts at zero. You can add items, take them out, sort them or go through them one by one. Python calls its array a list. Arrays are the most common way to keep many things of the same kind together.

Example code

python
>>> fruits = ["apple", "pear", "plum"]
>>> fruits[0]
'apple'
>>> len(fruits)
3
Three items in a row. The first one sits at spot 0.

Common mistake

Counting from 1. The first item is at spot 0, so the last one is at the length minus one.

Key takeaways

  1. 1
    In order. Items keep the order you put them in.
  2. 2
    Starts at zero. The first spot is number 0.
  3. 3
    One name, many values. A single variable holds the whole row.

Compare

Learn it properly