For a general-purpose sequence, initialize a Python list: values = [1, 2, 3]. Python also has a typed standard-library array and NumPy arrays, which are useful for numeric data and multidimensional shapes. Choose the type that matches what you need; “array” can mean more than one thing in Python.
Choose the right Python array type
| Use case | Choose | Example |
|---|---|---|
| General-purpose sequence of Python objects | Built-in list | [1, 2, 3] |
| Typed numeric values without NumPy | Standard-library array.array |
array('i', [1, 2, 3]) |
| Numerical operations or rectangular multidimensional data | NumPy ndarray |
np.array([[1, 2], [3, 4]]) |
Python’s Data Structures tutorial describes list literals and list operations. The Python 3.14 array reference documents typed numeric arrays. NumPy’s Array creation guide and beginner’s guide cover ndarray creation and behavior.
Initialize a list for ordinary Python code
A list is usually the right answer when you want a sequence that can hold general Python objects. It can contain numbers, strings, or values of different types.
values = [1, 2, 3]
empty = []
zeros = [0] * 5
Use a list comprehension when each initial value is computed separately:
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitches#1 Best Overall
values = [make_value(i) for i in range(5)]
For a two-dimensional list whose rows should be independent, create each row with a comprehension:
row_count = 3
columns = 4
rows = [[0] * columns for _ in range(row_count)]
Avoid [[0] * columns] * row_count when you intend independent rows: that expression repeats references to the same inner list, so changing one row changes them all.
Rank #2
Create a typed numeric array with array.array
The standard-library array module stores numeric values using a specified type code. It is distinct from both a list and NumPy’s multidimensional ndarray.
from array import array
values = array('i', [1, 2, 3])
empty_ints = array('i')
The type code, such as 'i' in this example, determines the element type. This is a one-dimensional typed array; use NumPy if your task calls for multidimensional numerical operations.
Create a NumPy array from existing values
Use np.array() to turn a sequence into a NumPy array. Rectangular nested sequences create arrays with multiple dimensions:
import numpy as np
from_values = np.array([1, 2, 3])
from_nested_values = np.array([[1, 2], [3, 4]])
NumPy arrays are generally homogeneous and have a fixed total size after creation. Nested input should have a rectangular shape, and you can set dtype when the element type matters:
values = np.array([1, 2, 3], dtype=np.int32)
Initialize by shape with zeros, ones, or empty
When you know the dimensions but not the values, use a shape-based constructor. Specify the fill type when you need something other than the default floating-point type.
zeros = np.zeros((2, 3), dtype=int)
ones = np.ones((2, 3), dtype=np.float32)
np.zeros() defaults to float64; it creates integer zeros here because dtype=int is specified. np.ones() accepts a shape and dtype in the same way.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Best Value
np.empty() allocates an array without initializing its elements to a known value. Its contents are not guaranteed to be zero, so assign every element before reading it:
result = np.empty((2, 3), dtype=int)
result[:] = 0
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Choose between arange and linspace
For a sequence defined by increments, use np.arange(). Prefer integer start, stop, and step values when possible:
indexes = np.arange(0, 10, 2) # 0, 2, 4, 6, 8
For an exact number of evenly spaced points between endpoints, use np.linspace():
samples = np.linspace(0, 1, 5) # five values, including both endpoints
Floating-point increments with arange() can have rounding and endpoint subtleties. Use linspace() when the point count and endpoints are what matter.
Free tools Windows power users keep installed
One-click scans. No signup required.
Quick Recap
Quick answer: how do I create an empty array in Python?
Choose what “empty” means for your task:
empty = []creates an empty, general-purpose list.empty_ints = array('i')creates an empty typed standard-library array.empty = np.empty((2, 3))allocates a NumPy array with a shape but uninitialized contents; fill it before reading.
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.




