You can do it quite efficiently with a list comprehension:

a = [[0] * number_cols for i in range(number_rows)]
Answer from cheeyos on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › multi-dimensional-lists-in-python
Multi-dimensional Lists in Python - GeeksforGeeks
October 30, 2025 - In Python, a Multi-dimensional List is a list containing other lists, often used to represent structured data like matrices, tables or 2D arrays. It’s useful for storing and accessing data in rows and columns, commonly applied in data analysis, ...
Discussions

Multidimensional arrays?
If you just use normal lists, you can store whatever you like. data = [ [1, 2, 3], [4], [5, 6, 7, 8, 9, 10], ] And you can refer to them exactly as you say: data[2][3] which will give you 8. More on reddit.com
🌐 r/learnpython
10
1
September 15, 2023
Performance advise for managing a large multi-dimensional list in Python.
Currently, I'm just using Python's basic list functions. I'm comfortable handling the data, just worried about how it will scale. For argument's sake let's say I need all this data as fast as possible at a moment's notice. ... Data - A multidimensional list stored as a global. More on reddit.com
🌐 r/learnpython
6
2
September 6, 2024
🌐
Snakify
snakify.org › two-dimensional lists (arrays)
Two-dimensional lists (arrays) - Learn Python 3 - Snakify
For example, that's how you display two-dimensional numerical list on the screen line by line, separating the numbers with spaces: ... a = [[1, 2, 3, 4], [5, 6], [7, 8, 9]] for i in range(len(a)): for j in range(len(a[i])): print(a[i][j], end=' ') print() 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.
🌐
freeCodeCamp
freecodecamp.org › news › multi-dimensional-arrays-in-python
Multi-Dimensional Arrays in Python – Matrices Explained with Examples
December 11, 2025 - We'll now look at some examples of how to create and work with multi-dimensional arrays in Python using NumPy. To create a multi-dimensional array using NumPy, we can use the np.array() function and pass in a nested list of values as an argument.
🌐
DEV Community
dev.to › aatmaj › learning-python-basic-course-day-11-multidimensional-lists-and-tuples-3bfl
Learning Python-Basic course: Day 11, Multidimensional lists and Tuples - DEV Community
July 7, 2021 - >>> list=[[1,2,3],[2,3,4],[3,4,5]] >>> print(list[1]) [2, 3, 4] >>> print(len(list)) 3 >>> print(list[2][1]) 4 >>> print(len(list[0])) 3 >>> print(list) [[1, 2, 3], [2, 3, 4], [3, 4, 5]] >>> for i in range(0,len(list)): ... for j in range(0,len(list[i])): ... print(list[i][j]) ... 1 2 3 2 3 4 3 4 5 >>> for i in list: ... for c in i: ... print(c,end="") ... print() ... 123 234 345 · The last statement is the mysterious way python implements it's syntax. Rather than writing in range, we can easily take this shortcut. We can create multidimensional lists dynamically.
🌐
Reddit
reddit.com › r/learnpython › multidimensional lists - creating, reading and updating
r/learnpython on Reddit: Multidimensional Lists - creating, reading and updating
March 7, 2022 -

New to python but not other higher level languages.

I’m having difficulty understanding how to use multidimensional lists in python.

I have a list if 256 objects. Each object has 6 variables. In other languages, I could read and update/change similar to

object[0] = [1,2,3,4,5,6]

object[255] = [1,2,3,4,5,6] Etc.

I understand in python this isn’t possible, so I’ll have to revert to something similar to

object = [[0], [1,2,3,4,5,6]]

object = [[255], [1,2,3,4,5,6]]

And reading will be similar to

var1 = object[0][3]

print(var1)

But I can’t get my head around it or find easy to,understand examples.

Does anyone have any quick and easy to digest resources that could help me understand this a bit better?

Thanks!

Find elsewhere
🌐
Quora
quora.com › How-do-you-access-a-two-dimensional-list-in-Python
How to access a two-dimensional list in Python - Quora
Answer (1 of 2): You use []s for indexing twice: That said, if you really want a matrix, i.e., a 2-D array, you should use NumPy: Lists are containers, whereas NumPy arrays are mathematical objects. If you’re doing math, use NumPy, but if you’re just holding stuff, use lists.
🌐
Processing
py.processing.org › tutorials › 2dlists
Two-Dimensional Lists \ Tutorials
Python Mode for Processing extends the Processing Development Environment with the Python programming language.
🌐
Reddit
reddit.com › r/learnpython › multidimensional arrays?
r/learnpython on Reddit: Multidimensional arrays?
September 15, 2023 -

Hello!

I have 5 sets, each set contains a number of elements of variable length (eg. set 1 has 100 elements, set 2 has 150 and so on)

Is it possible to store these sets in a single structure?

For example, if I want to print the 35th elements of the 3rd set, I could call it simply by saying something like MyContainer[setN][elementN]

I was trying to use a 2D array but I can't initialize its shape, since each set has a variable number of elements.

Can anybody point me to the right direction / best practice?

Thank you

🌐
TutorialsPoint
tutorialspoint.com › article › multi-dimensional-lists-in-python
Multi-dimensional lists in Python
Multi-dimensional lists in Python are created using nested list comprehensions or by directly defining lists within lists.
🌐
LinuxConfig
linuxconfig.org › home › python multidimensional lists
Multidimensional Lists in Python Explained
February 24, 2017 - No, you don’t need to learn how to code in “The Upside Down,” but there are additional degrees of complexity to lists. Lists are used to hold data, but they are also used to categorize it. Values inside a list can be further broken down into other sets. That’s essentially what a ...
🌐
Reddit
reddit.com › r/learnpython › performance advise for managing a large multi-dimensional list in python.
r/learnpython on Reddit: Performance advise for managing a large multi-dimensional list in Python.
September 6, 2024 - However, as the list grows, it's likely the underlying structure will be broken into multiple smaller lists. Therefore, each index position you reference has some searching it does to find the correct index. This is my understanding of python's list implementation.
🌐
W3Schools
w3schools.com › python › python_lists.asp
Python Lists
List is a collection which is ordered and changeable. Allows duplicate members. Tuple is a collection which is ordered and unchangeable. Allows duplicate members. Set is a collection which is unordered, unchangeable*, and unindexed.
🌐
Hyperskill
hyperskill.org › learn › step › 15127
Multi-dimensional list
Hyperskill is an educational platform for learning programming and software development through project-based courses, that helps you secure a job in tech. Master Python, Java, Kotlin, and more with real-world coding challenges.
🌐
TutorialsPoint
tutorialspoint.com › article › how-do-i-create-a-multidimensional-list-in-python
How do I create a multidimensional list in Python?
September 16, 2022 - Multidimensional lists are lists within lists that allow you to store data in a table-like structure. You access elements using two indices: the first for the row and the second for the column, like .
🌐
LabEx
labex.io › tutorials › python-how-to-create-multidimensional-lists-438320
How to create multidimensional lists | LabEx
This tutorial will guide you through ... In Python, a multidimensional list is a list that contains other lists as its elements, creating a nested structure similar to a matrix or a grid....
🌐
AskPython
askpython.com › python › array › multidimensional-arrays
Multidimensional Arrays in Python: A Complete Guide - AskPython
February 27, 2023 - It is a Python library that gives users access to a multidimensional array object, a variety of derived objects (such as masked arrays and matrices), and a selection of functions for quick operations on arrays and multi-dimensional matrices. The standard way of Python language creates lists which are very similar to arrays but remember, there is a very slight difference between a List and an array in Python programming language.
🌐
Medium
soumenatta.medium.com › how-to-work-with-multidimensional-arrays-in-python-a-beginners-guide-bd437495c87
How to Work with Multidimensional Arrays in Python: A Beginner’s Guide | by Dr. Soumen Atta, Ph.D. | Medium
April 8, 2023 - One way to create a multidimensional array in Python is by using a list of lists. Each element in the list represents a row in the array, and each sub-list represents the elements in that row.