To initialize a list of size n in Python, multiply a one-item list by n: [None] * n gives n empty slots, and [0] * n gives n zeros. If each slot must hold its own list or object, use a comprehension instead:
slots = [None] * 5 # [None, None, None, None, None]
grid = [[] for _ in range(5)] # five separate lists
I ran every snippet below on Python 3.12.5 and NumPy 2.5.3.
Below you’ll see each method, the shared-list trap, a speed test and a NumPy option.
Initialize a list of size n with [value] * n
Multiplying a one-item list repeats that item, so you get exactly n items in one step.
Here I’m making seven slots for a week of daily sales, then filling Wednesday by index:
n = 7
daily_sales = [0.0] * n # one slot per day of the week
names = [None] * 4
print(daily_sales, len(daily_sales))
print(names)
daily_sales[2] = 1249.50 # fill a slot by index
print([f"${x:,.2f}" for x in daily_sales])
Output:
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] 7
[None, None, None, None]
['$0.00', '$0.00', '$1,249.50', '$0.00', '$0.00', '$0.00', '$0.00']
![python initialize list of size n multiply command prompt Command Prompt output of Python [0.0] * 7 creating a list of seven zeros, [None] * 4 and a sales value assigned by index](https://pythonguides.com/wp-content/uploads/2026/10/python-initialize-list-of-size-n-multiply-command-prompt.png)
Use 0.0 for totals and None for “not filled yet”. If you later need the total, see finding the sum of a list or array in Python.
Why does [[]] * n share one inner list across every row?
Multiplication copies references, not objects. That’s fine for immutable numbers and strings, but with a list inside, every slot points at the same inner list.
rows = [[]] * 3 # three references to ONE list
rows[0].append("Austin")
print(rows)
print(rows[0] is rows[1])
safe = [[] for _ in range(3)] # three separate lists
safe[0].append("Austin")
print(safe)
print(safe[0] is safe[1])
Output:
[['Austin'], ['Austin'], ['Austin']]
True
[['Austin'], [], []]
False
![python list of lists shared reference trap command prompt Command Prompt output showing Python [[]] * 3 sharing one inner list while a list comprehension creates separate lists](https://pythonguides.com/wp-content/uploads/2026/10/python-list-of-lists-shared-reference-trap-command-prompt.png)
[[]] * 3 shows up in all three rows; the comprehension version changes only the first.The fix is a comprehension, which builds a new inner list on every pass. I cover nested lists in more depth in my guide to a list of lists in Python, and grids in initializing a 2D array in Python.
Create a list of n elements with a list comprehension
Use a comprehension when each slot needs its own starting value, computed from the index.
n = 5
prices = [round(19.99 * (i + 1), 2) for i in range(n)]
from datetime import date, timedelta
start = date(2026, 10, 12)
week = [(start + timedelta(days=i)).isoformat() for i in range(n)]
print(prices)
print(week)
Output:
[19.99, 39.98, 59.97, 79.96, 99.95]
['2026-10-12', '2026-10-13', '2026-10-14', '2026-10-15', '2026-10-16']

Use _ as the loop variable when you don’t need the index. More patterns like this are in initializing an array in Python.
Use range() or an append loop to build a list of size n
For a counting sequence, list(range(n)) is the shortest option. An append loop suits steps that need several lines of logic.
n = 6
print(list(range(n))) # 0 .. n-1
print(list(range(1, n + 1))) # 1 .. n
orders = []
for i in range(n):
orders.append(f"ORD-{1001 + i}")
print(orders)
empty = []
try:
empty[3] = "x"
except IndexError as e:
print("IndexError:", e)
Output:
[0, 1, 2, 3, 4, 5]
[1, 2, 3, 4, 5, 6]
['ORD-1001', 'ORD-1002', 'ORD-1003', 'ORD-1004', 'ORD-1005', 'ORD-1006']
IndexError: list assignment index out of range
Look at the last line: an empty list has no index 3, so assigning to it raises IndexError. That’s the main reason to pre-size a list at all.
For counting from 1, creating an array from 1 to N in Python has more options.
Which way to initialize a list is fastest?
I timed four methods with timeit, building a 100,000-item list 50 times each. Your seconds will differ, but the order rarely does.
from timeit import timeit
n = 100_000
tests = {
"[0] * n": lambda: [0] * n,
"[0 for _ in range]": lambda: [0 for _ in range(n)],
"append loop": lambda: _append(n),
"list(range(n))": lambda: list(range(n)),
}
def _append(n):
out = []
for _ in range(n):
out.append(0)
return out
results = {name: timeit(fn, number=50) for name, fn in tests.items()}
fastest = min(results.values())
for name, t in sorted(results.items(), key=lambda kv: kv[1]):
print(f"{name:<20} {t:7.4f} s {t / fastest:5.1f}x")
Output:
[0] * n 0.0029 s 1.0x
list(range(n)) 0.0702 s 24.1x
[0 for _ in range] 0.0813 s 27.9x
append loop 0.1013 s 34.7x
![python initialize list speed comparison timeit command prompt Command Prompt output of Python timeit comparing [0] * n, a list comprehension, an append loop and list(range(n))](https://pythonguides.com/wp-content/uploads/2026/10/python-initialize-list-speed-comparison-timeit-command-prompt.png)
[0] * n comes out fastest, and the append loop is the slowest of the four.Multiplication wins because the list is built once in C. The append loop calls a method per item, so keep it for real per-item logic.
Initialize a fixed-size numeric array with NumPy
For math on every value, a NumPy array beats a list. np.zeros(n) gives n float zeros and np.full(n, 9.99) fills every slot with one value.
Call .tolist() if you need a plain list back. More on this in creating an array of zeros in Python.
List of size n methods compared
| Method | Best for | Separate objects? |
|---|---|---|
[x] * n | Numbers, strings, None | No (shared) |
[f(i) for i in range(n)] | Computed or mutable values | Yes |
list(range(n)) | Counting sequences | Yes |
| Append loop | Multi-line logic per item | Yes |
np.zeros(n) | Numeric math on arrays | N/A (array) |
If you’re working through lists and arrays, these pick up where this one stops:
- Create an empty array in Python
- Append to an array in Python
- Check the length of an array in Python
- Remove elements from an array in Python
Frequently asked questions
How do I create a list of size n in Python?
Use [None] * n for empty placeholders or [0] * n for zeros. Both return a list with exactly n items.
How do I create an empty list with a certain size?
Lists have no truly empty slots, so use a placeholder: [None] * n.
Why does changing one row change all rows in [[0] * 3] * 3?
The outer multiplication repeats one inner list three times. Use [[0] * 3 for _ in range(3)] to get separate rows.
Do I need to pre-size a list in Python?
Usually not, since lists grow with append(). Pre-size only when you’ll assign by index.
What’s the fastest way to initialize a list of size n?
[value] * n is the fastest for immutable values. A comprehension is the safe choice for mutable ones.
Where is list multiplication documented?
See common sequence operations in the Python docs.

Bijay Kumar is a 13-time Microsoft MVP with more than 18 years in software development, and the founder of Python Guides and TSinfo Technologies. He started out building .NET and SharePoint solutions at HP, TCS and KPIT before moving into Python, machine learning and AI, and he also builds web apps with TypeScript and React. He writes the tutorials here himself, and every example is run before publishing so you see the real output. More about Bijay · Microsoft MVP profile · LinkedIn