How to Delete Items from a List in Python with del
Sometimes you know where the items you don't want are: the second one, or everything after the first two. The del statement removes items by position, one at a time or a whole range with a slice. This guide trims a packing list twice, with real output from Python 3.15.2.
Syntax
del <list>[<index>]
del <list>[<start>:<stop>]
| Part | What it means |
|---|---|
<list>[<index>] | One item, by its position. The first item is 0, the last is -1 |
<list>[<start>:<stop>] | A slice: the items from <start> up to, not including, <stop>. Leave <stop> out to go to the end |
Python's tutorial: "There is a way to remove an item from a list given its index instead of its value: the del statement. This differs from the pop() method which returns a value. The del statement can also be used to remove slices from a list or clear the entire list".
Prerequisites
- uv and Python. This guide uses uv 0.13.10 with Python 3.15.2, in a project made with
uv init.
Step 1: Write the Script
items = ["tent", "stove", "lantern", "map", "rope"]
del items[1]
print(items)
del items[2:]
print(items)
![The del_items.py script in a macOS-style code window: a packing list of tent, stove, lantern, map and rope, then del items[1] and a print, then del items[2:] and another print.](https://strdewiridedevblogsprod.blob.core.windows.net/images/blog/programming/python/2026/python-del-list-items-01-code.webp)
del items[1]removes the item at position 1,"stove".del items[2:]removes everything from position 2 to the end of what's left.
Step 2: Run It
uv run python del_items.py
['tent', 'lantern', 'map', 'rope']
['tent', 'lantern']

The first del took out "stove", and the items after it moved up a place. The slice then removed "map" and "rope", the items from position 2 on. Both changed the same list: del doesn't make a copy.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
A position past the end, del items[10] | IndexError: list assignment index out of range | Check len(items) first |
del items without brackets | It deletes the variable, not its items: the next print(items) gives NameError: name 'items' is not defined. Did you mean: 'iter'? | Use del items[:] to empty the list |
Keeping the deleted item, removed = del items[0] | SyntaxError: invalid syntax: del is a statement and gives nothing back | Use items.pop(0), which returns the item |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The wrong item was deleted | Positions start at 0, so items[1] is the second item | Count from zero |
FAQ
Does a slice past the end fail too?
No. del x[5:] on a two-item list removed nothing and raised no error: slices stop at the end of the list.
How do I delete the last item?
del items[-1]: negative positions count from the end. On ['a', 'b', 'c', 'd'] it left ['a', 'b', 'c'].
Conclusion
del items[1] removed "stove" and del items[2:] removed the rest after "lantern", both in the same list.
Additional Resources
- The del statement — removing items and slices.
- The del statement reference — everything
delcan delete.
