Parallel arrays

Parallel arrays are two or more arrays that store related data in the same order. Each item at a specific index in one array is linked to the items at the same index in the other arrays.

For example:

  • One array could store names: [“Jane”, “John”, “Jess”]

  • Another could store their ages: [14, 16, 15]

Here, Jane is 14, John is 16, and Jess is 15 — their details are linked by their position in the arrays.

Array index names ages
0 "Jane" 14
1 "John" 16
2 "Jess" 15

Example Code

names = ["Jane", "John", "Jess"]
ages = [14, 16, 15]
for i in range(len(names)):
    print(names[i], ages[i])

Output

 Jane 14
 John 16
 Jess 15