I also don't recommend this, but you could use a numpy.chararray for this:

import numpy as np
arr = np.chararray((100, 12, 31, 24, 60, 60), itemsize=100)

arr[52, 7, 12, 12, 44, 54] = 'year 1950+52, 7th month, 12th day, 12th hour, 44th minute, 54th second'

I'm not exactly sure what your desired structure is, but the string I inserted into the array should explain the structure I proposed, and you can change it however you need. Note that itemsize limits how many characters you can put in at any index.

Again, with a caveat that this is not necessarily the most efficient thing in the world to do, but if you wish to store lists of ints and/or floats in that array (as per your comment), one way to do it would be to convert that list to strings, and then when retrieving it, re-transform back to a list:

data_to_insert = [1,2,3,4.5]
# store as string
arr[52, 7, 12, 12, 44, 54] = ','.join(map(str, data_to_insert))
# retrieve
arr[52, 7, 12, 12, 44, 54].decode('utf-8').split(',')

This should be pretty fast

Answer from sacuL on Stack Overflow
Top answer
1 of 2
2

I also don't recommend this, but you could use a numpy.chararray for this:

import numpy as np
arr = np.chararray((100, 12, 31, 24, 60, 60), itemsize=100)

arr[52, 7, 12, 12, 44, 54] = 'year 1950+52, 7th month, 12th day, 12th hour, 44th minute, 54th second'

I'm not exactly sure what your desired structure is, but the string I inserted into the array should explain the structure I proposed, and you can change it however you need. Note that itemsize limits how many characters you can put in at any index.

Again, with a caveat that this is not necessarily the most efficient thing in the world to do, but if you wish to store lists of ints and/or floats in that array (as per your comment), one way to do it would be to convert that list to strings, and then when retrieving it, re-transform back to a list:

data_to_insert = [1,2,3,4.5]
# store as string
arr[52, 7, 12, 12, 44, 54] = ','.join(map(str, data_to_insert))
# retrieve
arr[52, 7, 12, 12, 44, 54].decode('utf-8').split(',')

This should be pretty fast

2 of 2
2

Though i won't recommend it, A multi dimentional empty list can be created by using list comprehension:

> >>> a = 4 #Width of elements
> >>> b = 6 #Width of main list container
>>>>> c = 4
>>>>> d = 3
> >>> l = [[[[0 for k in range(d) ] for z in range(c)] for x in range(a)] for y in range(b)]
> >>> [[[[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, 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, 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], [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, 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, 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], [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, 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, 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], [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, 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, 0]], [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]]]

Keep replacing 0 with list comprehensions to add more dimentions.

🌐
Quora
quora.com › How-do-you-create-an-empty-multidimensional-array-in-Python
How to create an empty multidimensional array in Python - Quora
Answer (1 of 5): You can’t - a multidimensional list (not array) in Python is a list of lists. if the top level list is empty then it isn’t multidimensional - it is an empty list. if the list on the next level down are empty then you have a list which is N by zero - hardly multi-dimensional.
🌐
GitHub
gist.github.com › gonzacaminos › 16c830ffda05128a3481ea86ddd0024c
Create an empty multidimensional list in Python · GitHub
Create an empty multidimensional list in Python · Raw · empty_multidimensional_list.py · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
🌐
w3resource
w3resource.com › python-exercises › list › python-data-type-list-exercise-85.php
Python: Create a multidimensional list with zeros - w3resource
June 28, 2025 - ... # Create an empty multidimensional list 'nums' nums = [] # Loop over a range of 3 times to create 3 sublists for i in range(3): # Append an empty sublist to 'nums' for each iteration nums.append([]) # Loop over a range of 2 times to fill ...
🌐
Ubaldo Acosta Soto
ictdemy.com › python › basics › multidimensional-lists-in-python
Lesson 10 - Multidimensional lists in Python - ICTdemy.com
We have to keep in mind the outer list can be empty. We'll nest the loops in order so that the outer loop iterates over the rows and the inner one over the columns of the current row. After printing a row, we must break a line. Both loops must have a different control variable: {PYTHON} # declaration and adding columns cinema = [] for j in range(5): column = [] for i in range(5): column.append(0) cinema.append(column) # filling with data cinema[2][2] = 1 # center for i in range(1, 4): # fourth row cinema[i][3] = 1 for i in range(5): # the last row cinema[i][4] = 1 cols = len(cinema) rows = 0 if cols: rows = len(cinema[0]) for j in range(rows): for i in range(cols): print(cinema[i][j], end = "") print()
🌐
DaniWeb
daniweb.com › programming › software-development › threads › 160559 › empty-2d-array
python - Empty 2D Array [SOLVED] | DaniWeb
December 3, 2008 - If your data are sparse (many empty cells), a dictionary keyed by (row, col) avoids allocating full rows: from collections import defaultdict grid = defaultdict(dict) grid[r][c] = value # only store populated cells · For heavy numeric work, prefer NumPy arrays for performance and vectorization; initialize once you know dimensions: arr = numpy.zeros((rows, cols)) (NumPy zeros). More on the aliasing gotcha: Python FAQ: multidimensional lists.
🌐
Statistics Globe
statisticsglobe.com › home › python programming language for statistics & data science › create empty 2d list in python (2 examples)
Create Empty 2D List in Python (2 Examples) | Zero Elements
March 31, 2023 - Run the code block below in your preferred Python IDE: rows = 3 cols = 4 my_list = [] for i in range(rows): row = [] for j in range(cols): row.append(None) my_list.append(row) print(my_list) # [[None, None, None, None], [None, None, None, None], ...
Find elsewhere
🌐
Snakify
snakify.org › two-dimensional lists (arrays)
Two-dimensional lists (arrays) - Learn Python 3 - Snakify
A possible way: you can create ... one-dimensional list of m elements: ... Another (but similar) way: create an empty list and then append a new element to it n times (this element should be a list of length m):...
🌐
GeeksforGeeks
geeksforgeeks.org › python-using-2d-arrays-lists-the-right-way
Python | Using 2D arrays/lists the right way - GeeksforGeeks
Manually initializing and populating ... using "Naive Methods". ... Here we are multiplying the number of rows by the empty list and hence the entire list is created with every element zero....
Published: June 20, 2024
🌐
Brainly
brainly.com › computers and technology › college › complete the code to create a multidimensional list. ```python listb = [] listb.append([4, 6, 8, 10]) ```
[FREE] Complete the code to create a multidimensional list. python listB = [] listB.append([4, 6, 8, 10]) - brainly.com
December 14, 2024 - To create a multidimensional list in Python, initialize an empty list and append nested lists to it. In your example, listB becomes [[4, 6, 8, 10]]. You can keep adding more nested lists to increase its complexity.
🌐
Dot Net Perls
dotnetperls.com › 2d-python
Python - 2D List Examples - Dot Net Perls
# Step 1: create a list. # ... Append empty lists in first two indexes. elements = [] elements.append([]) elements.append([]) # Step 2: add elements to empty lists.
🌐
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 - # Create a Multi-Dimensional Python List mylist = [[2, 5], [10, 24, 68], [80]] print("Original Multidimensional List") for row in mylist: print(row) # Append a new row mylist.append([65, 24]) print("\nAfter appending [65, 24]:") for row in mylist: ...
🌐
Ubuntu Forums
ubuntuforums.org › archive › index.php › t-950128.html
Python empy three-dimensional lists [Archive] - Ubuntu Forums
October 17, 2008 - This isn't aesthetically pleasing, but I just implemented the following: vals = [] for i in range(len(phidict)): vals.append([]) for j in range(len(yeardict)): vals[i].append([]) for k in range(7): vals[i][j].append([]) Perhaps not the best python solution, but for a c-coder like myself, it did the trick. Yeah, no kidding, I could smell C programmer from here. Btw, what is that supposed to be? yeardict? timedate module not good enough? ... curlyNY has got it right. I have recently tried to do this and you can't just declare 2d lists like that, you have to iterate through them.
🌐
Quora
quora.com › How-do-you-create-an-empty-2D-list-in-Python
How to create an empty 2D list in Python - Quora
Answer (1 of 10): C̲r̲e̲a̲t̲i̲n̲g̲ ̲a̲n̲ e̲m̲p̲t̲y̲ ̲2̲D̲ ̲li̲s̲t̲ ̲i̲n̲ ̲P̲y̲t̲h̲o̲n̲ ̲i̲s̲ ̲s̲t̲r̲a̲i̲g̲h̲t̲f̲o̲r̲w̲ar̲d̲ ̲,̲ ̲b̲u̲t̲ ̲u̲n̲d̲e̲r̲s̲t̲a̲n̲di̲n̲g̲ ̲t̲h̲e̲ ̲n̲u̲a̲n̲c̲e̲s̲ ̲e̲ns̲u̲r̲e̲s̲ ...
🌐
Finxter
blog.finxter.com › home › learn python blog › how to create a two dimensional array in python?
How To Create a Two Dimensional Array in Python? - Be on the Right Side of Change
June 11, 2022 - Here’s a diagrammatic representation ... you want to create an empty 2D array without using any external libraries, you can use nested lists....