Multidimensional array in Python

A multidimensional array in Python consisting of two dimensions can be interpreted as a grid. Three dimensions are like a cube and more than three dimensions are difficult to illustrate. 

WHAT IS A MULTIDIMENSIONAL ARRAY IN Python?

In Python, it is possible to create an array in several, what is described as, dimensions. We considered a Array as lists of values. Similarly, we can see a Multidimensional Array in two dimensions as a grid (matrices with rows and columns) and for anMultidimensional Array with three dimensions as a block / cube. This means that we get more indexes and it is usually described as list by list, which means that the rows can have different lengths.

Multidimensional Array in Java

CREATE A MULTIDIMENSIONAL ARRAY IN Python

 

We declare a multidimensional array similarly to one-dimensional arrays.

 

twoField = [[value1, value2, value3 so on..],   # Row 1
             value4, value5, value6 so on..]]   # Row 2

 

Let’s add some values to our twoField array that we saw in the image in the begging of this page – to make it i bit more clear how it works

 

twoField = [[2, 98, 36],  # Row 1
            [15, 4, 57],  # Row 2
            [22, 0, 82],  # Row 3
            [22, 55, 8]]  # Row 4

 

If we put the numbers in our image it becomes

Multidimensional Array Python

Similarly, we can create an array of three dimensions that can be likened to a cube and an array of higher dimensions than is understandably difficult to illustrate in the image.

For more information about the Multidimensional Array we recommend the Python Docs website