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
Discussions

python - Create a dynamic 2D numpy array on the fly - Stack Overflow
Depending on what create_row() ... the Python loop altogether. ... Sign up to request clarification or add additional context in comments. ... Just pass the list of lists to numpy.array, keep in mind that numpy arrays are ndarrays, so the concept to a list of lists doesn't translate to arrays of arrays it translates to a 2d ... More on stackoverflow.com
🌐 stackoverflow.com
How to define a dynamic two-dimensional array in python? - Stack Overflow
I want to define a dynamic two-dimensional array in python. I don't know how many rows my two-dimensional array will have at the start of my program. I would like to define new rows in this 2D arr... More on stackoverflow.com
🌐 stackoverflow.com
July 13, 2011
How to take integer dynamic 2d-array as input in python(Online IDE) - Stack Overflow
I want to take a 2d array of free size as user input in python in an online compiler where the number of rows and columns are not defined. For example if the input is : 1 2 3 4 5 6 7 8 9 10 11 12 ... More on stackoverflow.com
🌐 stackoverflow.com
create a dynamic two dimensional array in python (loop) - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
🌐 stackoverflow.com
June 12, 2017
🌐
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
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-using-2d-arrays-lists-the-right-way
Using 2D arrays/lists in Python - GeeksforGeeks
Python creates only one inner list and one 0 object, not separate copies. This shared reference behavior is known as shallow copying (aliasing). If we assign the 0th index to another integer say 1, then a new integer object is created with the value of 1 and then the 0th index now points to this new int object as shown below · Similarly, when we create a 2d array as "arr = [[0]*cols]*rows" we are essentially extending the above analogy.
Published: December 20, 2025
Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 68398366 › how-to-take-integer-dynamic-2d-array-as-input-in-pythononline-ide
How to take integer dynamic 2d-array as input in python(Online IDE) - Stack Overflow
I want to take a 2d array of free size as user input in python in an online compiler where the number of rows and columns are not defined. For example if the input is : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I want to store it like [[1,2,3,4],[5,6,7],[8,9],[10],[11,12,13,14,15]] ... You should know that online IDE throws an EOF error when there are excess input statments in code but no input given considering this We can take dynamic input in online IDE.
🌐
GeeksforGeeks
geeksforgeeks.org › python-using-2d-arrays-lists-the-right-way
Python | Using 2D arrays/lists the right way - GeeksforGeeks
In Python, List, Array and Tuple are data structures for storing multiple elements. Lists are dynamic and hold mixed types, Arrays are optimized for numerical data with the same type and Tuples are immutable, ideal for fixed collections.
Published: June 20, 2024
🌐
Stack Overflow
stackoverflow.com › questions › 39487235 › create-a-dynamic-two-dimensional-array-in-python-loop
create a dynamic two dimensional array in python (loop) - Stack Overflow
June 12, 2017 - $i = 1; $arr= array(); foreach($mes as $res){ $arr[$i]->type = $res->item; $arr[$i]->action = $res->title; $i++ } how can i make that code in python? i need to built that code dynamically for the foreach loop as you can see in the code above..i need to assign the values..arr[1]['type'] = 'blabla', arr[1]['action] = 'blabla'..i hope you understand what i am trying to do
🌐
Snakify
snakify.org › two-dimensional lists (arrays)
Two-dimensional lists (arrays) - Learn Python 3 - Snakify
To process 2-dimensional array, you typically use nested loops. The first loop iterates through the row number, the second loop runs through the elements inside of a row.
🌐
GeeksforGeeks
geeksforgeeks.org › implementation-of-dynamic-array-in-python
Implementation of Dynamic Array in Python | GeeksforGeeks
May 12, 2023 - A dynamic array can, once the array is filled, allocate a bigger chunk of memory, copy the contents from the original array to this new space, and continue to fill the available slots.
🌐
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.
January 8, 2024 -

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?

🌐
Drbeane
drbeane.github.io › python_dsci › pages › array_2d.html
2-Dimensional Arrays — Python for Data Science
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. This process can be performed with other arithmetic operations, and is referred to as broadcasting.
🌐
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...
🌐
TutorialsPoint
tutorialspoint.com › python_data_structure › python_2darray.htm
Python - 2-D Array
Python TechnologiesDatabasesComputer ... QualityManagement Tutorials View All Categories ... Two dimensional array is an array within an array. It is an array of arrays. In this type of array the position of an data element is ...
🌐
Scaler
scaler.com › home › topics › 2d array in python
2D Array in Python | Python Two-Dimensional Array - Scaler Topics
May 25, 2026 - Learn about 2D array in python by Scaler Topics. A two-dimensional array in Python is a nested data structure, meaning it is a set of arrays inside another array.
🌐
Python.org
discuss.python.org › python help
Need help with a two-dimensional array - Python Help - Discussions on Python.org
June 3, 2022 - Hello there! I’m an experienced coder who’s just getting into Python for the first time. I know several versions of BASIC, Pascal, C, C++, C#, PHP, MySQL… and so on. 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.