To remove the first occurrence of an element, use list.remove:

>>> xs = ['a', 'b', 'c', 'd']
>>> xs.remove('b')
>>> print(xs)
['a', 'c', 'd']

To remove all occurrences of an element, use a list comprehension:

>>> xs = ['a', 'b', 'c', 'd', 'b', 'b', 'b', 'b']
>>> xs = [x for x in xs if x != 'b']
>>> print(xs)
['a', 'c', 'd']
Answer from Johannes Charra on Stack Overflow
🌐
thisPointer
thispointer.com › home › list › python: remove elements from list by value
Python: Remove elements from list by value - thisPointer
September 11, 2023 - We should first check if the element exists in the list or not before calling the remove() function. For example, list_of_num = [51, 52, 53, 54, 55, 52, 57, 52, 59] elem = 70 if elem in list_of_num: list_of_num.remove(elem) print(list_of_num)
Discussions

Remove elements from a list
Hi guys! I’m new in python. I just have a simple question: I have two Lists of int (the lists have different number of elements). I have to check if the elements of List2 exist in List1. If the elements already exist, I want to remove them from List1. I made this code: list1 = [1,2,3,4,5... More on discuss.python.org
🌐 discuss.python.org
4
0
March 14, 2021
python - Is there a simple way to delete a list element by value? - Stack Overflow
Technically, this comprehension does not remove an element. It creates a new list, which might be a problem if the list is an argument to the function or typed as Final. The fix is simple: instead of xs = ..., use xs[:] = .... 2023-01-06T16:59:23.397Z+00:00 ... Save this answer. ... Show activity on this post. Usually Python ... More on stackoverflow.com
🌐 stackoverflow.com
python - Remove items from list if it exists - Stack Overflow
My code will not delete the items if they exist in the list. This is the list I am working with: [1, 2, 3, 4, 5, 6, 7, 8] Run the function: remove_items_from_list(my_list, [1,5,6]) This is the O... More on stackoverflow.com
🌐 stackoverflow.com
How to remove items from one list and put them in another list while in a For loop?
if you want to remove specific items and put them in a list just .append and .remove them, if you want to use .pop that also works. More on reddit.com
🌐 r/learnpython
19
2
December 1, 2022
🌐
Great Learning
mygreatlearning.com › blog › it/software development › how to remove an item from a list in python
How to Remove an Item from a List in Python
June 11, 2025 - In this course, you will learn the fundamentals of Python: from basic syntax to mastering data structures, loops, and functions. You will also explore OOP concepts and objects to build robust programs. ... Using remove(): Remove a specific item ...
🌐
Python.org
discuss.python.org › python help
Remove elements from a list - Python Help - Discussions on Python.org
March 14, 2021 - Hi guys! I’m new in python. I just have a simple question: I have two Lists of int (the lists have different number of elements). I have to check if the elements of List2 exist in List1. If the elements already exist, I want to remove them from List1. I made this code: list1 = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19] list2 = [9,17] for i in range(len(list1)): for j in range(len(list2)): if list2[j] == list1[i]: list1.remove(ground[i]) but I received an error massage: Index...
🌐
GeeksforGeeks
geeksforgeeks.org › python › remove-item-from-list-in-python
How to Remove Item from a List in Python - GeeksforGeeks
For example, remove() can be used to remove the first occurrence of a specified value from a list. ... remove() method removes the first occurrence of a specified value from the list. If the value appears multiple times, only the first occurrence ...
Published: July 15, 2025
🌐
datagy
datagy.io › home › python posts › remove an item from a python list (pop, remove, del, clear)
Remove an Item from a Python List (pop, remove, del, clear) • datagy
December 19, 2022 - In order to accomplish this, we can use a while loop in order to repeat an action while a statement continues to be true. In particular, our while loop will continue to remove the item from our list while the item still exists in our list.
Find elsewhere
🌐
freeCodeCamp
freecodecamp.org › news › python-list-remove-how-to-remove-an-item-from-a-list-in-python
Python List .remove() - How to Remove an Item from a List in Python
March 2, 2022 - The condition was that if an item in the original list has a value of Python, it would not be part of the sublist. Now, if you don't want to create a new list, but instead want to modify the already existing list in-place, then use the slice assignment combined with list comprehension.
🌐
Note.nkmk.me
note.nkmk.me › home › python
Remove an Item from a List in Python: remove, pop, clear, del | note.nkmk.me
April 17, 2025 - In Python, you can remove items (elements) from a list using methods such as remove(), pop(), and clear(). You can also use the del statement to delete items by index or slice. Additionally, list comprehensions can be used to create a new list ...
🌐
Delft Stack
delftstack.com › home › howto › python › delete element from list by value
How to Delete Element From List in Python | Delft Stack
February 2, 2024 - In this code block, we will delete the list element by using the remove() built-in method. The remove() method deletes the first found element with the matched value in a given list.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python remove set element if exists
Python Remove Set Element If Exists - Spark By {Examples}
May 31, 2024 - How to remove an element from Python Set by checking if an element exists? If you want to remove the element only if it exists in the set. You can use the
🌐
Learn By Example
learnbyexample.org › python-list-remove-method
Python List remove() Method - Learn By Example
December 22, 2022 - L = ['red', 'green', 'blue'] L.remove('yellow') # Triggers ValueError: list.remove(x): x not in list · To avoid such exception, you can check if item exists in a list, using in operator inside if statement.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-list-remove
Python List remove() Method - GeeksforGeeks
July 17, 2026 - Example 2: Here, the same value appears multiple times in the list. The remove() method removes only the first matching occurrence. ... Explanation: a.remove(5) removes only the first occurrence of 5. The remaining occurrences stay unchanged.
🌐
Sentry
sentry.io › sentry answers › python › delete a list element by value in python
Delete a list element by value in Python | Sentry
June 15, 2024 - Python’s list.remove method provides this functionality. Given a value, it will search for that value in the list and delete the first instance it finds. If the supplied value is not found in the list, it raises a ValueException error.
🌐
GUVI
guvi.in › blog › programming languages › remove element from python list: 5 methods with code + speed comparison
How to remove an element from a list in Python (2026 Guide)
August 17, 2026 - You would need to iterate through each sublist and remove elements using any of the methods mentioned. Not exactly. my_list.clear() empties the list in place, so all references to that list object still point to the same (now empty) list. Assigning my_list = [] creates a brand new list object, which other references to the old list won’t see. Python raises a ValueError. To avoid this, check if the value exists first using the “in” operator: if “apple” in my_list: my_list.remove(“apple”).
🌐
Boot.dev
blog.boot.dev › python › complete guide to removing elements from lists in python
Complete Guide to Removing Elements From Lists in Python | Boot.dev
December 9, 2021 - primes = [2, 3, 5, 5, 7, 11] primes.remove(5) print(primes) # [2, 3, 5, 7, 11] primes.remove(5) # [2, 3, 7, 11] primes.remove(5) # careful, this will throw an error # ValueError: list.remove(x): x not in list · If you want to safely remove items, and you aren't sure if they exist in the list or not, you can either catch the error:
🌐
Guru99
guru99.com › home › python › remove element from a python list [clear, pop, remove, del]
Remove element from a Python LIST [clear, pop, remove, del]
July 11, 2026 - Removing elements from a Python list relies on three built-in methods, remove(), pop(), and clear(), plus the del keyword, each targeting an item by value, by index, or clearing the entire list in place.
🌐
W3Schools
w3schools.com › python › python_lists_remove.asp
Python - Remove List Items
Python Dictionaries Access Items Change Items Add Items Remove Items Loop Dictionaries Copy Dictionaries Nested Dictionaries Dictionary Methods Dictionary Exercises Code Challenge Python If...Else
🌐
Vultr Docs
docs.vultr.com › python › standard library › list › remove()
Python List Remove() - Remove Element
November 11, 2024 - Note the slicing used in the loop to create a copy of the list for iteration, avoiding modification issues during the loop. The remove() function in Python provides a reliable method to delete elements from a list based on their value.