Python's Keyword to Delete List Items

Benjamin Jul 11, 2026

When working with lists in Python, you might find the need to remove an item at some point. The keyword you're looking for is remove(). This built-in method allows you to delete the first occurrence of a specified value from a list.

a table with words that are used to describe the keywords for each keyword
a table with words that are used to describe the keywords for each keyword

Let's dive into how to use this method and explore some related topics to help you understand it better.

Keywords in python
Keywords in python

Understanding the remove() Method

The remove() method is a list method in Python that takes one argument, the value to be removed. It searches for the first occurrence of this value in the list and removes it.

an info sheet with the words important method in python, set list and keywords
an info sheet with the words important method in python, set list and keywords

Here's a simple example:

```python list1 = [1, 2, 3, 2, 4] list1.remove(2) print(list1) ```

This will output: [1, 3, 2, 4]. As you can see, the first occurrence of 2 has been removed.

Python List Methods Everyone Must Know
Python List Methods Everyone Must Know

What if the value is not found?

If the value you're trying to remove is not in the list, Python will raise a ValueError. To avoid this, you can use the try-except block:

```python list1 = [1, 2, 3, 2, 4] try: list1.remove(5) except ValueError: print("The value is not in the list") ```

Removing all occurrences of a value

Python Lists Explained Deeply (With Examples & Practice)
Python Lists Explained Deeply (With Examples & Practice)

If you want to remove all occurrences of a value, you can't use remove() directly, as it only removes the first occurrence. Instead, you can use a while loop:

```python list1 = [1, 2, 3, 2, 4, 2] while 2 in list1: list1.remove(2) print(list1) ```

This will output: [1, 3, 4], removing all occurrences of 2.

Alternative Ways to Remove Items

a computer screen showing the different types of commands and symbols for each type of device
a computer screen showing the different types of commands and symbols for each type of device

While remove() is the most straightforward way to remove an item from a list, it's not the only way. Let's explore a couple of alternatives.

Using list comprehension

a poster with the words, what is list slicing in python? and how to use it
a poster with the words, what is list slicing in python? and how to use it
All Important Python Functions for Beginners (Complete Cheat Sheet)
All Important Python Functions for Beginners (Complete Cheat Sheet)
a poster with instructions on how to use the python remove duplicates from a list
a poster with instructions on how to use the python remove duplicates from a list
Python Lists with Examples
Python Lists with Examples
"6 Python List Methods Every Beginner Should Know"
"6 Python List Methods Every Beginner Should Know"
an image of some cats with the words python list in front of them and below it
an image of some cats with the words python list in front of them and below it
When to use List Comprehension in Python
When to use List Comprehension in Python
a poster with the words reverse a list in python and an image of a programming program
a poster with the words reverse a list in python and an image of a programming program
Emojis in python
Emojis in python
Python Programming Language Guide, Learn Python For Science Students, Python Programming For Science, Programming Projects, Learn Python, Learn Python In One Picture, Python Learning, Python Aesthetic, Python Projects
Python Programming Language Guide, Learn Python For Science Students, Python Programming For Science, Programming Projects, Learn Python, Learn Python In One Picture, Python Learning, Python Aesthetic, Python Projects
a poster with different types of text and numbers on the back ground, including words that are
a poster with different types of text and numbers on the back ground, including words that are
a poster with different types of text on it
a poster with different types of text on it
30-Day Python Learning Plan for Beginners | Complete Python Roadmap to Learn Coding Fast
30-Day Python Learning Plan for Beginners | Complete Python Roadmap to Learn Coding Fast
a screenshot of a computer screen with the text looping through dictionaries in python
a screenshot of a computer screen with the text looping through dictionaries in python
Python list methods every developer should know.
Python list methods every developer should know.
Python Cheatsheet
Python Cheatsheet
Python Basics Cheat Sheet for Beginners
Python Basics Cheat Sheet for Beginners
an info sheet with the words 10 python one - liners that will blow your mind
an info sheet with the words 10 python one - liners that will blow your mind
an image of a screen with the words sort list in python and numbers on it
an image of a screen with the words sort list in python and numbers on it
Lists in Python 💻
Lists in Python 💻

You can use list comprehension to create a new list that doesn't include the value you want to remove:

```python list1 = [1, 2, 3, 2, 4] list1 = [i for i in list1 if i != 2] print(list1) ```

This will output: [1, 3, 4], effectively removing all occurrences of 2.

Using the del statement

The del statement can also be used to remove items from a list. It's particularly useful when you know the index of the item you want to remove:

```python list1 = [1, 2, 3, 2, 4] del list1[1] print(list1) ```

This will output: [1, 3, 2, 4], removing the item at index 1.

In conclusion, while the remove() method is the most direct way to remove an item from a list in Python, there are other methods you can use depending on your specific needs. Experiment with these methods to find the one that works best for you.