Find the non – unique elements in a list in python

Removing elements of a list while iterating over it is never a good idea. The appropriate way to do this would be to use a collections.Counter with a list comprehension

If you want keep the duplicate elements in the order in which they appear in your list:

Leave a Reply

Your email address will not be published. Required fields are marked *