Python has a language feature called List Comprehensions that is perfectly suited to making this sort of thing extremely easy. The following statement does exactly what you want and stores the result in l3:

l3 = [x for x in l1 if x not in l2]

l3 will contain [1, 6].

Answer from Donut on Stack Overflow
🌐
W3Schools
w3schools.com › python › python_lists_remove.asp
Python - Remove List Items
The list still remains, but it has no content. ... Coding fundamentals as bite-sized lessons and challenges. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
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
Removing a specific element from a list
lst.index(thing) will get you the index of the first occurrence of thing in lst (it will raise an error if it's not in list, so be aware that you have to handle that). lst.pop(index) will remove whatever is at index. If your first list could possibly have duplicates, you'll have to be careful with your current method (though it's still pretty close). Also note, you don't need is in, just in More on reddit.com
🌐 r/learnpython
7
3
January 23, 2021
[Lists] Removing values from one list and Transfering it to another(While vs For Loop)
The real key is that you can't generally shouldn't remove an element from a list you're iterating over. That's true in most programming languages. For example, take this simplified code: fruits = ['apple','banana','strawberry','mango' ] for fruit in fruits: fruits.remove(fruit) print(fruits) You might expect it to print nothing, but it actually prints ['banana', 'mango'] Why? First, the loop will look at the 0th element in the list ('apple') and enter the loop body. Here, it removes that element, so the list is now ['banana', 'strawberry', 'mango' ]. Now the iteration moves on to the next element in the list - it just did element 0, so now it moves to element 1, but element 1 is now 'strawberry', and that gets deleted, too, so you have ['banana', 'mango'] left. At this point, it tries to move on to element 2 in the list, but there are only elements 0 and 1, so the loop terminates. If you did want a loop that removes an element from the list each time, just do something like this: fruits = ['apple','banana','strawberry','mango' ] while fruits: fruit = fruits.pop(0) print(fruit) print(fruits) More on reddit.com
🌐 r/learnpython
14
7
January 11, 2024
Remove multiple elements from a list
Filter "Mango" out with a list comprehension: a = [fruit for fruit in a if fruit != "Mango"] A longer version would be: new_a = [] for fruit in a: if fruit != "Mango": new_a.append(fruit) a = new_a Edit: Thanks u/ClutchAlpha More on reddit.com
🌐 r/learnpython
11
1
August 3, 2022
🌐
GeeksforGeeks
geeksforgeeks.org › python › remove-multiple-elements-from-a-list-in-python
Remove Multiple Elements from List in Python - GeeksforGeeks
We iterate over each element in remove list. The while loop make sure that all occurrences of each element are removed from the list.
Published: October 28, 2025
🌐
Real Python
realpython.com › remove-item-from-list-python
How to Remove Items From Lists in Python – Real Python
October 21, 2025 - In this code snippet, you call .pop() on the original book list, which only contains four elements. You used the .pop() method for the item at index 50, but this is out of range because the list isn’t that big, so it raises an IndexError.
🌐
StrataScratch
stratascratch.com › blog › how-to-remove-an-element-from-a-list-in-python
How to Remove an Element from a List in Python - StrataScratch
October 3, 2025 - Let’s explore each method individually. Each method for removing elements from a list serves a different use case. Here’s how to decide: Use remove() when you want to delete the first occurrence of a specific value.
🌐
Edureka
edureka.co › blog › python-list-remove
Remove Elements From Lists | Python List remove() Method | Edureka
February 6, 2025 - In Example 2, we use the del operator to remove elements from a range of indices, i.e. from index position 1 till index position 4 (but not including 4). Subsequently, when you print myList, you can see the elements at index position 1,2 and ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › remove-item-from-list-in-python
How to Remove Item from a List in Python - GeeksforGeeks
The removed element is stored in val. ... The del statement removes an element by its index or removes multiple elements using a slice. ... The list is modified in place. A slice can be used with del to remove multiple elements from a list.
Published: 3 days ago
Find elsewhere
🌐
DataCamp
datacamp.com › tutorial › python-remove-item-from-list
How to Remove an Item from a List in Python: A Full Guide | DataCamp
August 1, 2024 - In the first case, we can use the remove() function. # Initialize a list with integers from 1 to 5 my_list = [1, 2, 3, 4, 5] # Removes element 5 from the list my_list.remove(5) print(my_list) # Expected output: [1, 2, 3, 4]
🌐
ReqBin
reqbin.com › code › python › niedpzpq › python-list-remove-example
How do I remove an element from a list in Python?
December 22, 2022 - To remove items from a list using the del statement in Python, you need to specify the position or range of the item(s) to be removed by index. The first index is 0, and the last index is -1. You can also delete the entire list by specifying ...
🌐
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 ...
🌐
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 - To remove an element from a list using the remove() method, specify the value of that element and pass it as an argument to the method. remove() will search the list to find it and remove it.
🌐
Programiz
programiz.com › python-programming › methods › list › remove
Python List remove() (with Code Visualization)
Online Python Online JavaScript Online SQL Online Java Online HTML Online C Online C++ Online C# Online PHP Online Swift Online Kotlin Online TypeScript Online Go Online Rust Online Scala Online Dart Online R Online Ruby ... The remove() method removes the first matching item from a list.
🌐
Index.dev
index.dev › blog › remove-item-from-python-list
Python List Remove: Delete Elements from List (7 Methods + Code) | Index.dev
May 14, 2025 - Use pop() or del when you know the position: python # Python delete from list by index names = ['Alice', 'Bob', 'Charlie', 'Diana'] # Using pop() - returns the removed item removed = names.pop(2) # Removes 'Charlie' print(removed) # 'Charlie' # Using del - doesn't return anything del names[0] # Removes 'Alice' print(names) # ['Bob', 'Diana'] The remove() method ...
🌐
AskPython
askpython.com › python › list › remove-elements-from-a-list
How to remove elements from a list in Python? - AskPython
July 21, 2020 - To remove multiple elements from a list in a sequence, we need to provide a range of elements to the del statement. A range of elements take a starting index and/or an ending index, separated by a colon ':'. The values to be deleted include ...
🌐
H2K Infosys
h2kinfosys.com › home › python tutorials › removing elements from a list in python
Removing Elements from a List in Python | H2K Infosys Blog
December 10, 2025 - This often involves removing unwanted elements from lists. ... Removing missing or null values that could skew results in data analysis. Filtering out duplicate or redundant data to maintain accuracy. Eliminating outliers or incorrect entries from datasets. ... pythondata = ["apple", "", "banana", None, "cherry", ""] # List with empty and None values cleaned_data = [item for item in data if item] # Remove empty strings and None values print(cleaned_data)
🌐
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 - Each item sits at a unique index position, starting from 0. Understanding how indexing works is the key to using list removal methods correctly. Let’s get into it. Explore HCL GUVI’s free Python resource and master all the fundamentals of programming: Python eBook · Just like depicted in the picture above, all the elements in the lists are enclosed within square brackets [ ], and every element in the list is separated by a comma (,).
🌐
SitePoint
sitepoint.com › python hub › remove list items
Python - Remove List Items | SitePoint — SitePoint
Here, we first check if the element exists in the list before attempting to remove it. The pop() method removes an element at a specified index and returns its value. ... If no index is provided, it removes and returns the last element.
🌐
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...
🌐
Tutorialspoint
tutorialspoint.com › python › python_remove_list_items.htm
Python - Remove List Items
The following example shows how ... print ("List after popping: ", list2) ... The clear() method in Python is used to remove all elements from a list, leaving it empty....
🌐
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.