If by "array" you actually mean a Python list, you can use

Use with AIa = [0] * 10

or

Use with AIa = [None] * 10
Answer from Sven Marnach on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-initialize-empty-array-of-given-length
Python - Initialize empty array of given length - GeeksforGeeks
In this example, we are using Python List comprehension for 1D and 2D empty arrays. Using list comprehension like [[0] * 4 for i in range(3)] creates independent lists for each row.
Published: July 12, 2025
🌐
Python Guides
pythonguides.com › create-an-empty-array-in-python
Python Empty Array: Create, Declare, Size N and NumPy
January 12, 2026 - Create an empty array in Python with [], declare one of size n, avoid the [[]] * n trap, use the array module or NumPy, and check if an array is empty.
Discussions

python - How do I check if a list is empty? - Stack Overflow
Comparing the length of an array to 0 to determine emptiness is standard practice in c and almost all c influenced languages (c++, java, c#, etc). 2019-04-14T04:52:39.347Z+00:00 ... Coming from a language that claims to be some sort of poetry, this mechanism is pure garbage. Semantically, being empty is very different to not being 2020-04-04T14:03:17.647Z+00:00 ... The Pythonic way to do it is from the PEP 8 style guide. For sequences, (strings, lists... More on stackoverflow.com
🌐 stackoverflow.com
python - How do I create an empty array and then append to it in NumPy? - Stack Overflow
I want to create an empty array and append items to it, one at a time. xs = [] for item in data: xs.append(item) Can I use this list-style notation with NumPy arrays? More on stackoverflow.com
🌐 stackoverflow.com
python - How to create a list of empty lists - Stack Overflow
0 How to store data in a double dimensional array in Python? 0 content from multiple txt files into single excel file using python · 41 How to create a list or tuple of empty lists in Python? More on stackoverflow.com
🌐 stackoverflow.com
Create an empty list with certain size in Python - Stack Overflow
Admittedly, that's not the Pythonic way to do things. Better do this: ... The other great thing about this is that you can initialise a list with default values. lst = [''] * 10 or lst = [0] * 10 2016-09-14T03:47:00.76Z+00:00 ... A variant on the comprehension example. If all elements in the array need to be empty ... More on stackoverflow.com
🌐 stackoverflow.com
People also ask

How do I create an empty array in Python?
Use an empty list: items = []. For typed numbers use array("d") from the array module, and for math use NumPy's np.array([]).
🌐
pythonguides.com
pythonguides.com › create-an-empty-array-in-python
Python Empty Array: Create, Declare, Size N and NumPy
How do I declare an empty array of size n in Python?
Python doesn't declare sizes, but [None] * n or [0] * n gives you n slots to fill by index. With NumPy, np.zeros(n) does the same.
🌐
pythonguides.com
pythonguides.com › create-an-empty-array-in-python
Python Empty Array: Create, Declare, Size N and NumPy
Is a Python list the same as an array?
Not exactly. A list holds any mix of types and grows freely, while array.array and NumPy arrays hold one numeric type. For most code, a list is what people mean by an array in Python.
🌐
pythonguides.com
pythonguides.com › create-an-empty-array-in-python
Python Empty Array: Create, Declare, Size N and NumPy
🌐
freeCodeCamp
freecodecamp.org › news › python-empty-list-tutorial-how-to-create-an-empty-list-in-python
Python Empty List Tutorial – How to Create an Empty List in Python
June 18, 2020 - If you want to learn how to create an empty list in Python efficiently, then this article is for you. You will learn: How to create an empty list using square brackets []. How to create an empty list using list(). Their use cases. How efficient th...
🌐
CodeGenes
codegenes.net › blog › how-to-create-an-empty-array-in-python
Creating Empty Arrays in Python: A Comprehensive Guide — codegenes.net
The most straightforward way to create an empty array in Python is by using the built - in list type.
Find elsewhere
Top answer
1 of 16
612

That is the wrong mental model for using NumPy efficiently. NumPy arrays are stored in contiguous blocks of memory. To append rows or columns to an existing array, the entire array needs to be copied to a new block of memory, creating gaps for the new elements to be stored. This is very inefficient if done repeatedly.

Instead of appending rows, allocate a suitably sized array, and then assign to it row-by-row:

>>> import numpy as np

>>> a = np.zeros(shape=(3, 2))
>>> a
array([[ 0.,  0.],
       [ 0.,  0.],
       [ 0.,  0.]])

>>> a[0] = [1, 2]
>>> a[1] = [3, 4]
>>> a[2] = [5, 6]

>>> a
array([[ 1.,  2.],
       [ 3.,  4.],
       [ 5.,  6.]])
2 of 16
150

A NumPy array is a very different data structure from a list and is designed to be used in different ways. Your use of hstack is potentially very inefficient... every time you call it, all the data in the existing array is copied into a new one. (The append function will have the same issue.) If you want to build up your matrix one column at a time, you might be best off to keep it in a list until it is finished, and only then convert it into an array.

e.g.


mylist = []
for item in data:
    mylist.append(item)
mat = numpy.array(mylist)

item can be a list, an array or any iterable, as long as each item has the same number of elements.
In this particular case (data is some iterable holding the matrix columns) you can simply use


mat = numpy.array(data)

(Also note that using list as a variable name is probably not good practice since it masks the built-in type by that name, which can lead to bugs.)

EDIT:

If for some reason you really do want to create an empty array, you can just use numpy.array([]), but this is rarely useful!

🌐
iO Flood
ioflood.com › blog › python-empty-list-guide-to-using-empty-lists-in-python
Python Empty List | Guide to Using Empty Lists in Python
June 27, 2024 - So, whether you’re a beginner ... embark on this journey! You can create an empty list in Python using either square brackets [] or the list() function....
🌐
DataCamp
datacamp.com › home › tutorials › python › a comprehensive guide to python empty lists
A Comprehensive Guide to Python Empty Lists | DataCamp
February 2, 2024 - def find_strings_starting_with_a(strings): # Initialize an empty list to store strings that start with 'A' strings_starting_with_a = [] # Iterate over the input list and append strings that start with 'A' to `strings_starting_with_a` for string in strings: if string.startswith('A'): strings_starting_with_a.append(string) return strings_starting_with_a # Example usage result = find_strings_starting_with_a(['Assert', 'Import', 'Function', 'Array', 'Arguments']) # 'result' will contain ['Assert', 'Array', 'Arguments'] ... In summary, mastering empty lists and their operations is crucial in Python programming, allowing for versatile data manipulation.
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-initialize-an-empty-array-of-given-length-using-python
How to Initialize an Empty Array of given Length using Python
March 27, 2026 - Empty array using range() and append(): [None, None, None, None, None] Length: 5 · List comprehension provides a concise way to create empty arrays ?
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-check-if-list-empty-not
Check if a list is empty or not in Python - GeeksforGeeks
October 24, 2024 - Explanation: len(a) returns 0 for an empty list. Lists can be directly evaluated in conditions. Python considers an empty list as False.
🌐
Quora
quora.com › How-do-I-create-an-empty-array-in-Python
How to create an empty array in Python - Quora
Answer (1 of 6): The closest thing to an array in Python is a list, which is dynamic (the size can change). This is somewhat similar to a C++ [code ]std::vector[/code] or a Java [code ]ArrayList[/code] (if you’re familiar with those languages and data structures). To make an empty list, you ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › declare-an-empty-list-in-python
Declare an Empty List in Python - GeeksforGeeks
July 12, 2025 - We can create an empty list in Python by just placing the sequence inside the square brackets[]. To declare an empty list just assign a variable with square brackets.
Top answer
1 of 16
1381

You cannot assign to a list like xs[i] = value, unless the list already is initialized with at least i+1 elements (because the first index is 0). Instead, use xs.append(value) to add elements to the end of the list. (Though you could use the assignment notation if you were using a dictionary instead of a list.)

Creating an empty list:

>>> xs = [None] * 10
>>> xs
[None, None, None, None, None, None, None, None, None, None]

Assigning a value to an existing element of the above list:

>>> xs[1] = 5
>>> xs
[None, 5, None, None, None, None, None, None, None, None]

Keep in mind that something like xs[15] = 5 would still fail, as our list has only 10 elements.

range(x) creates a list from [0, 1, 2, ... x-1]

# 2.X only. Use list(range(10)) in 3.X.
>>> xs = range(10)
>>> xs
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Using a function to create a list:

>>> def display():
...     xs = []
...     for i in range(9): # This is just to tell you how to create a list.
...         xs.append(i)
...     return xs
... 
>>> print display()
[0, 1, 2, 3, 4, 5, 6, 7, 8]

List comprehension (Using the squares because for range you don't need to do all this, you can just return range(0,9) ):

>>> def display():
...     return [x**2 for x in range(9)]
... 
>>> print display()
[0, 1, 4, 9, 16, 25, 36, 49, 64]
2 of 16
233

Try this instead:

lst = [None] * 10

The above will create a list of size 10, where each position is initialized to None. After that, you can add elements to it:

lst = [None] * 10
for i in range(10):
    lst[i] = i

Admittedly, that's not the Pythonic way to do things. Better do this:

lst = []
for i in range(10):
    lst.append(i)

Or even simpler, in Python 2.x you can do this to initialize a list with values from 0 to 9:

lst = range(10)

And in Python 3.x:

lst = list(range(10))
🌐
GeeksforGeeks
geeksforgeeks.org › declare-an-empty-list-in-python
Declare an Empty List in Python - GeeksforGeeks
May 1, 2025 - Declaring an empty list in Python creates a list with no elements, ready to store data dynamically.
🌐
Codemia
codemia.io › home › knowledge hub › create an empty list with certain size in python
Create an empty list with certain size in Python | Codemia
January 8, 2025 - Forgetting that array.array and bytearray exist. For typed numeric data, they use a fraction of the memory that a Python list requires. Using np.empty() without overwriting every element.
🌐
Built In
builtin.com › articles › python-check-if-list-is-empty
Python Check if a List Is Empty: A Guide | Built In
There are a variety of methods that can be used to check if a list is empty in Python, including the Truth Value Testing method, the len() function and the == operator. Learn more.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-check-if-a-list-is-empty-in-python
Python isEmpty() equivalent – How to Check if a List is Empty in Python
April 19, 2023 - In the code above, we used an if statement and the not operator to check if the people_list was empty. You can use the len() function in Python to return the number of elements in a data structure.