Nest lists in lists you don't need to predefine the length of a list to use it and you can append on to it. Want another dimension simply append another list to the inner most list.

[[[a1, a2, a3]  , [b1, b2, b3] , [c1, c2, c3]],
[[d1, d2, d3]  , [e1, e2, e3] , [f1, f2, f3]]]

and to use them easily just look at Nested List Comprehensions

Answer from VoronoiPotato on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-using-2d-arrays-lists-the-right-way
Using 2D arrays/lists in Python - GeeksforGeeks
The code below, compares two ways of initializing a 2D list in Python. Using list multiplication ([[0]*cols]*rows) creates multiple references to the same inner list, causing aliasing where changes affect all rows. Using a nested list comprehension creates a separate list for each row, avoiding aliasing and correctly forming a 2D array.
Published ย  December 20, 2025
๐ŸŒ
YouTube
youtube.com โ€บ watch
Python declaring dynamic arrays and multi-dimensional arrays - YouTube
How to declare dynamic arrays?How to declare multi-dimensional arrays?List is a dynamic arrays in pythonyou can append or fill values2 or more dimensional li...
Published ย  August 14, 2019
๐ŸŒ
Quora
quora.com โ€บ How-can-you-declare-a-dynamic-array-in-Python
How to declare a dynamic array in Python - Quora
Answer (1 of 7): Array support in Python is obtained from the array module: This module defines an object type that can efficiently represent an array of basic values: characters, integers, floating point numbers. Arrays are types of sequence and behave like lists, except that the type of object...
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python-using-2d-arrays-lists-the-right-way
Python | Using 2D arrays/lists the right way - GeeksforGeeks
A 2D array is essentially a list of lists, which represents a table-like structure with rows and columns. In Python, Initializing a collection of elements in a linear sequence requires creating a 1D array, which is a fundamental process.
Published ย  June 20, 2024
๐ŸŒ
Snakify
snakify.org โ€บ two-dimensional lists (arrays)
Two-dimensional lists (arrays) - Learn Python 3 - Snakify
We have already tried to explain that a for-loop variable in Python can iterate not only over a range(), but generally over all the elements of any sequence. Sequences in Python are lists and strings (and some other objects that we haven't met yet). Look how you can print a two-dimensional array, using this handy feature of loop for:
๐ŸŒ
Guru99
guru99.com โ€บ home โ€บ python โ€บ python 2d arrays: two-dimensional list examples
Python 2D Arrays: Two-Dimensional List Examples
August 12, 2024 - Creare 2D array with 4 rows and 5 columns array=[[23,45,43,23,45],[45,67,54,32,45],[89,90,87,65,44],[23,45,67,32,10]] #use for loop to iterate the array for rows in array: for columns in rows: print(columns,end=" ") print() Output: 23 45 43 23 45 45 67 54 32 45 89 90 87 65 44 23 45 67 32 10 ยท Operators in Python โ€“ Logical, Arithmetic, Comparison ยท
๐ŸŒ
Javatpoint
javatpoint.com โ€บ python-2d-array
Python 2D array - Javatpoint
Python 2D array with python, tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, operators, etc.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ two dimensional list - dynamically creating it does not work, while manually works fine.
r/learnpython on Reddit: Two Dimensional List - dynamically creating it does not work, while manually works fine.
November 24, 2023 -

I have a class where it should create a 2D list depending on the given size x and y. However, noticed that the following does not work.

self.grid = [[0] * self.sizeY] * self.sizeX
self.grid[1][0] = "TEST"

The output:

[['TEST', 0, 0, 0, 0], ['TEST', 0, 0, 0, 0], ['TEST', 0, 0, 0, 0], ['TEST', 0, 0, 0, 0], ['TEST', 0, 0, 0, 0]]

While the following works fine as expected:

self.grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
self.grid[1][0] = "TEST"

The output:

[[0, 0, 0, 0, 0], ['TEST', 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]

As you can see in the first example when the result is not what is expected, location [1][0] is being stored 5 times as if all 'rows' are the same.

Any ideas on how to create the 2D list dynamically?

๐ŸŒ
Sentry
sentry.io โ€บ sentry answers โ€บ python โ€บ define a two-dimensional array in python
Define a two-dimensional array in Python | Sentry
How can I create an empty two-dimensional array in Python, e.g. for matrix operations? The best way to create two-dimensional (2D) arrays or matrices is by using Pythonโ€™s numpy module, which provides comprehensive and performant functionality for manipulating multidimensional arrays.
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ 2d array in python
2D Array in Python | Python Two-Dimensional Array - Scaler Topics
October 10, 2025 - Traversing means sequentially accessing each value of a structure. Traversing in a 2D array in python can be done by using a for a loop. We can iterate through the outer array first, and then at each element of the outer array, we have another array, our internal array containing the elements.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ implementation-of-dynamic-array-in-python
Implementation of Dynamic Array in Python - GeeksforGeeks
May 12, 2023 - import ctypes class DynamicArray(object): ''' DYNAMIC ARRAY CLASS (Similar to Python List) ''' def __init__(self): self.n = 0 # Count actual elements (Default is 0) self.capacity = 1 # Default Capacity self.A = self.make_array(self.capacity) def __len__(self): """ Return number of elements stored in array """ return self.n def __getitem__(self, k): """ Return element at index k """ if not 0 <= k < self.n: # Check it k index is in bounds of array return IndexError('K is out of bounds !') return self.A[k] # Retrieve from the array at index k def append(self, ele): """ Add element to end of the array """ if self.n == self.capacity: # Double capacity if not enough room self._resize(2 * self.capacity) self.A[self.n] = ele # Set self.n index to element self.n += 1 def insertAt(self, item, index): """ This function inserts the item at any specified index.
๐ŸŒ
iO Flood
ioflood.com โ€บ blog โ€บ python-2d-array
Python 2D Array with Lists | Guide (With Examples)
February 10, 2024 - As you can see, Python lists (or arrays) are very flexible. They can store items of different types, and they can be resized dynamically (items can be added or removed).
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
Need help with a two-dimensional array - Python Help - Discussions on Python.org
June 2, 2022 - Hereโ€™s what I have: 1 2 3 4 5 6 7 8 A X X X X X X X X B X X X X X T X X C X X X X X X X X D X X X X X X X X E X X X X X X X X F X X X X X X X X G X X X X X X X X H X X X X X X X X This is a simple two-dimensional array.
๐ŸŒ
Drbeane
drbeane.github.io โ€บ python_dsci โ€บ pages โ€บ array_2d.html
2-Dimensional Arrays โ€” Python for Data Science
In certain situations, we can perform arithmetic operations on arrays with different sizes. One such scenario is adding a 2D array with a single row to another 2D array. If the two arrays have the same number of columns, then the row array will be added to each row of the other array.