Python Programming - Lists - Discussion

Discussion Forum : Lists - General Questions (Q.No. 47)
47.
How can you remove all occurrences of a specific element from a list in Python?
list.remove_all(element)
list.delete(element)
list.remove(element, all=True)
list = [x for x in list if x != element]
Answer: Option
Explanation:
To remove all occurrences of a specific element, you can use a list comprehension to filter out the unwanted element.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.