Remove Multiple Elements from List in Python
Last Updated :
28 Oct, 2025
Given a list of numbers, the task is to remove multiple specified elements from it. Removing multiple elements means eliminating all occurrences of these elements and returning a new list with the remaining numbers.
For example:
a = [10, 20, 30, 40, 50, 60, 70]
remove = [20, 40, 60]
Resulting list = [10, 30, 50, 70]
Let’s explore different methods to remove multiple elements from a list.
Using List Comprehension
This method uses list comprehension and creates a new list by including only those elements that are not in the remove list.
Python
a = [10, 20, 30, 40, 50, 60, 70]
remove = [20, 40, 60]
a = [x for x in a if x not in remove]
print(a)
Explanation: Iterates through each element in a and includes it in the new list only if it is not in the remove list.
Using filter() Function
filter() function can be used to remove elements from a list by providing a filtering condition and typically through a lambda function.
Python
a = [10, 20, 30, 40, 50, 60, 70]
remove = {20, 40, 60}
a = list(filter(lambda x: x not in remove, a))
print(a)
Explanation:
- filter() function iterates over the list a and applying the lambda function.
- If an element is not in remove list then include it in the filtered list.
Using For Loop
This method iterates through the list and manually appends only the elements that are not in the remove list.
Python
a = [10, 20, 30, 40, 50, 60, 70]
remove = [20, 40, 60]
res = []
for val in a:
if val not in remove:
res.append(val)
print(res)
Explanation:
- Iterates through each element of a.
- Adds the element to a new list res only if it is not in remove.
Using remove() in a Loop
remove() method removes the first occurrence of a specified element from the list. To remove multiple elements, we can use a loop to repeatedly call remove().
Python
a = [10, 20, 30, 40, 50, 60, 70]
remove = [20, 40, 60]
for val in remove:
while val in a:
a.remove(val)
print(a)
Explanation:
- We iterate over each element in remove list.
- The while loop make sure that all occurrences of each element are removed from the list.
Python program to Remove multiple elements from a List
Explore
Python Fundamentals
Python Data Structures
Advanced Python
Data Science with Python
Web Development with Python
Python Practice