August 2024
Intermediate to advanced
256 pages
5h 34m
English
A 2D list is a list of lists. It allows you to store data in a tabular form with rows and columns. Each element in a 2D list represents a value at a specific row and column position.
my_2d_list = [
[ 21, 8, 17, 4 ],
[ 2, 16, 9, 19 ],
[ 8, 21, 14, 3 ],
[ 3, 18, 15, 5 ]
]
You can visualise this as a grid similar to a table with rows and columns. Each column in the grid is numbered starting with 0.

Each row is numbered starting with 0. Each cell in the grid is identified by an index - the row index followed by the column index as shown as shown in figure 1 below.
If you want to reference a value in the 2D list, first reference ...
Read now
Unlock full access