In python, multiple dimensional array is slightly different. Its not like C/C++ or that kind of language. I'm giving you an example code regarding two dimensional array, and small explanation of it.
Here is a way to declare a 5x5 array at python.
This will give you 5x5 2-d array. What does that code mean? Here,
Initialize Value = 0
for col in range(5) = create a linear or one dimensional array with 5 field and all are initialized with 0.
Now change the initializing value,
Initialize Value = [0 for col in range(5) ]
for row in range(5) = on each five rows of your array will contain a copy of above array.
So each row has pointing to another row. Which is nothing but a 2-d array.
Here is a way to declare a 5x5 array at python.
array = [ [0 for col in range(5) ] for row in range(5)]
This will give you 5x5 2-d array. What does that code mean? Here,
Initialize Value = 0
for col in range(5) = create a linear or one dimensional array with 5 field and all are initialized with 0.
Now change the initializing value,
Initialize Value = [0 for col in range(5) ]
for row in range(5) = on each five rows of your array will contain a copy of above array.
So each row has pointing to another row. Which is nothing but a 2-d array.
Comments
array = [[0]*5] * 5
[[0]*5 for row in range(5)]
[[0]*5 for row in range(5)]