Array of Records

Example Code Snippet

An array of records is an array where each element is a record. It lets you store multiple sets of related data in an organised way.

For example, an array of pupil records might look like this:

class Pupil:
    name = str
    age = int

# Create a pupil array
pupils = [Pupil() for i in range(5)]

# Display all pupils
for i in range(len(pupils)):
    print(pupils[i].name, pupils[i].age)

Each pupil is a record, and all the records are stored in one array. This is more organised and readable than using parallel arrays.