Say I had a list called "list1" list1 = [1,2,3,4,5]
and I had another list called "list2" list2 = [1,2,3]
What would be the easiest way to take out 1,2,3 without using a loop to iterate through list2 then deleting them from list1?
Thanks!
Asked
Active
Viewed 45 times
0

The shape
- 359
- 3
- 10
-
1Does the following answer your question? https://stackoverflow.com/questions/6486450/python-compute-list-difference – j1-lee May 29 '21 at 21:54
-
With `in` operator you can test if an item is in "list2" (but technically this is a hidden loop). – Michael Butscher May 29 '21 at 21:56