# Index

> The number of a spot in a list. In most languages the first spot is 0.

**Field:** Software Development  
**Category:** Programming Concepts  
**Also known as:** Array Index, Position

## Think of it like

Think of it like a seat number at the cinema. It tells you which seat is yours.

## Definition

An index is the number of a spot in an array or a string. Most languages start counting at 0, so the first item has index 0. You use the index in square brackets to read or change one item, like fruits[2]. Asking for an index past the end gives an error. Some languages also count back from the end with -1.

## Example

Jack asks for fruits[3] in a list of three fruits. Python stops with an IndexError, because the spots are 0, 1 and 2.

## Example code

```python
>>> fruits = ["apple", "pear", "plum"]
>>> fruits[2]
'plum'
>>> fruits[3]
IndexError: list index out of range
```

Spot 2 is the last fruit. Spot 3 does not exist, so Python stops.

## Why it matters

Every time code picks one item out of many, it uses an index. Getting it one off is a very common bug.

## Common mistake

Being off by one: starting at 1, or going one step past the end of the list.

## Three principles

- **A spot number.** It says where an item sits.
- **Zero first.** The first item is at index 0.
- **Stay in range.** Past the end is an error.

## Related terms

- [Array](https://learn.benibix.com/term/development/array)
- [String](https://learn.benibix.com/term/development/string)
- [Loop](https://learn.benibix.com/term/development/loop)
- [Runtime Error](https://learn.benibix.com/term/development/runtime-error)
- [Off-by-One Error](https://learn.benibix.com/term/development/off-by-one-error)

## Taught in

- [Lists, Dictionaries and Sets](https://learn.benibix.com/learn/development-concepts/lists-dictionaries-and-sets): Programming Basics, 8/18

---

Source: https://learn.benibix.com/term/development/index
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
