I know “for” is not what you want, but it’s simple and clear:
for x in b:
a.remove(x)
Or if members of b
might not be in a
then use:
for x in b:
if x in a:
a.remove(x)
More Related Contents:
- Is there a short contains function for lists?
- How to add numbers inside a variable? [closed]
- Python – get unique and sorted values in list of lists [closed]
- Remove all the elements that occur in one list from another
- Copying nested lists in Python
- Finding the average of a list
- Negative list index? [duplicate]
- Merge lists that share common elements
- How to overcome TypeError: unhashable type: ‘list’
- python; modifying list inside a function
- Dynamic variable in Python [duplicate]
- Appending a dictionary to a list – I see a pointer like behavior
- Appending item to lists within a list comprehension
- Removing elements from a list containing specific characters [duplicate]
- Tuple unpacking order changes values assigned
- Reversing a list using slice notation
- Convert string to list. Python [string.split() acting weird]
- How do you split reading a large csv file into evenly-sized chunks in Python?
- How to convert nested list of lists into a list of tuples in python 3.3?
- Numpy individual element access slower than for lists
- list.extend and list comprehension [duplicate]
- Pairwise crossproduct in Python [duplicate]
- How to allow list append() method to return the new list
- Pythonic Circular List
- What’s the difference between plus and append in python for list manipulation? [duplicate]
- Assign multiple values of a list
- TypeError: list indices must be integers or slices, not list
- Deleting consonants from a string in Python
- Filter a list of tuples based on condition
- How can I convert this string to list of lists? [duplicate]