How to Repeat a List in Python with *
Sometimes you need a list that holds the same items several times: five zeros to start counting from, or one word repeated to build a test text. In Python, * between a list and a whole number repeats the list's items that many times. This guide repeats three lists on Python 3.15.2.
Syntax
<list> * <times>
| Part | What it means |
|---|---|
<list> | The list whose items are repeated |
<times> | A whole number: how many times the items appear in the new list. <times> * <list> works too |
The Python documentation on sequence operations describes s * n or n * s as "equivalent to adding s to itself n times". The result is a new list; the original stays as it was.
The Example
Three lists: two cheers repeated twice, a single zero repeated five times, and a laugh repeated three times and joined into one text.
Prerequisites
- uv and Python 3. This guide uses uv 0.13.10 with Python 3.15.2, in a project made with
uv init.
Step 1: Write the Script
cheers = ["hip", "hip"] * 2
print(cheers)
zeros = [0] * 5
print(zeros)
print(" ".join(["ha"] * 3))

Step 2: Run It
uv run python repeat.py
['hip', 'hip', 'hip', 'hip']
[0, 0, 0, 0, 0]
ha ha ha

["hip", "hip"] * 2repeated both items twice, in order: four items.[0] * 5made a list of five zeros from a list of one.["ha"] * 3made a list of three"ha", and" ".join(...)put spaces between them.
The command works unchanged in PowerShell.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Repeating a list that holds a list, such as [[]] * 3 | The documentation warns that "items in the sequence s are not copied; they are referenced multiple times", so all three are one list. Its example, adding 3 to the first of them, printed [[3], [3], [3]] when I ran it | Make a new list for each, as the documentation's own fix does: [[] for i in range(3)] |
Expecting * 2 to double every number in a list | * repeats the items, as ["hip", "hip"] * 2 did; it doesn't multiply them | Multiply each item, for example with a list comprehension |
FAQ
Does the order matter, list first or number first?
No. 3 * [0] printed [0, 0, 0], the same as [0] * 3.
What happens with 0 or a negative number?
You get an empty list: [0] * 0 and [0] * -2 both printed []. The documentation: "Values of n less than 0 are treated as 0 (which yields an empty sequence of the same type as s)."
Conclusion
["hip", "hip"] * 2 gave four items, [0] * 5 five zeros, and ["ha"] * 3 three laughs: * repeated each list's items in a new list.
Additional Resources
- Common Sequence Operations —
s * nand its notes, including the[[]] * 3example.
