How to have an array of arrays in Python

3

From Microsoft documentation:

A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes

Python documentation about Data Structures.

You could store a list inside another list or a dictionary that stores a list. Depending on how deep your arrays go, this might not be the best option.

numbersList = []

listofNumbers = [1,2,3]
secondListofNumbers = [4,5,6]

numbersList.append(listofNumbers)
numbersList.append(secondListofNumbers)

for number in numbersList:
    print(number) 

Leave a Comment