A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/remove-multiple-elements-from-a-list-in-python/ below:

Remove Multiple Elements from List in Python

Remove Multiple Elements from List in Python

Last Updated : 11 Jul, 2025

In this article, we will explore various methods to remove multiple elements from a list in Python. The simplest way to do this is by using a loop. A simple for loop can also be used to remove multiple elements from a list.

Python
a = [10, 20, 30, 40, 50, 60, 70]

# Elements to remove
remove = [20, 40, 60]

# Remove elements using a simple for loop
res = []

for val in a:
    if val not in remove:
        res.append(val)

print(res)

Explanation

Let's explore other different ways to remove multiple elements from list:

Using List Comprehension

List comprehension is one of the most concise and efficient ways to remove multiple elements from a list.

Python
a = [10, 20, 30, 40, 50, 60, 70]

# Elements to remove
remove = [20, 40, 60]

# Remove elements using list comprehension
a = [x for x in a if x not in remove]

print(a)

Explanation:

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]

# Elements to remove
remove = [20, 40, 60]

# Remove elements using remove() in a loop
for val in remove:
    while val in a:
        a.remove(val)

print(a)

Explanation:

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]

# Elements to remove
remove = {20, 40, 60}

# Remove elements using filter
a = list(filter(lambda x: x not in remove, a))

print(a)

Explanation:


Python program to Remove multiple elements from a List


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4