How do you delete an item from a list in Python?

Experience Level: Junior
Tags: Python

Answer

To delete an item from the list, use del statement.

Example:
# The code belows deletes "amber" item from the list.

items = list["red", "amber", "green"]
del list[1]

Python for beginners
Python for beginners

Are you learning Python ? Try our test we designed to help you progress faster.

Test yourself