Use [] to create an empty built-in Python list: items = []. For a zero-element NumPy array, use np.array([])—and specify dtype if the element type matters. NumPy’s np.empty(shape) is different: it allocates an array whose values are uninitialized, not a zero-element array.
What does “empty array” mean in Python?
Python has a built-in sequence type called a list, while NumPy provides the ndarray type for numerical array operations. The phrase “empty array” can refer to either an empty list or a NumPy array, so choose the syntax based on the type and behavior your code needs.
As an Amazon Associate I earn from qualifying purchases.
| What you want | Use | What it creates |
|---|---|---|
| Flexible, empty Python sequence | items = [] |
A mutable list with no elements |
| NumPy array with zero elements | np.array([], dtype=float) |
An ndarray with no elements and an explicitly selected dtype |
| NumPy array of a chosen shape, with values to fill later | np.empty(shape) |
Allocated array storage whose values are uninitialized |
| NumPy array of a chosen shape, initialized to zero | np.zeros(shape, dtype=...) |
An array whose elements start at zero |
Create an empty Python list with []
For general-purpose Python code, the simplest empty sequence is a list:
items = []
items.append("first")
Lists are mutable and can grow as you append values. They can also hold values of different types. The Python tutorial’s data-structures documentation describes lists and their operations.
#1 Best Overall
[] creates a list, not a NumPy ndarray. If later code specifically expects NumPy array behavior, create an ndarray instead.
Create a zero-element NumPy array
Import NumPy, then pass an empty sequence to np.array:
Rank #2
import numpy as np
empty_vector = np.array([], dtype=float)
This creates an ndarray with zero elements. The optional dtype argument selects the data type for array elements; specifying it is useful when later code depends on a particular type. NumPy documents the accepted inputs and optional data type in its numpy.array reference.
Recommended Free Tools
If the dtype is not important to your use case, the shorter form is np.array([]). Use an explicit dtype when you want the intended type to be clear and stable.
Why np.empty(shape) is not a zero-element array
The name can be misleading: np.empty(shape) creates an array with the requested shape, but it does not initialize ordinary numeric values to zero. Its elements contain arbitrary values until your code assigns them. For example:
buffer = np.empty(3, dtype=int)
buffer[:] = [10, 20, 30]
Assign every element before reading from the array. NumPy describes this behavior in the numpy.empty reference. Use it when you intend to fill allocated storage yourself—not when you need an array with zero elements or zero-valued elements.
Use np.zeros when values must start at zero
If you need a NumPy array of a particular shape and every element should begin at zero, use np.zeros:
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorszeros = np.zeros(3, dtype=int)
This creates a three-element integer array initialized with zeros. The numpy.zeros reference documents the shape and dtype parameters.
Best Value
Choose a list or a NumPy array
- Choose a list for a flexible, general-purpose sequence that you may grow or use for mixed types.
- Choose a NumPy array when your data and operations suit numerical arrays, and you want an ndarray.
- Choose
np.array([])when the NumPy array should contain zero elements. - Choose
np.empty(shape)only when you need allocated storage and will assign values before reading them. - Choose
np.zeros(shape)when the array needs elements initialized to zero.
NumPy’s beginner guide introduces arrays and how they differ from Python lists.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




