Get a unique list of items that occur more than once in a list

You can use collections.Counter to do what you have described easily:

from collections import Counter
mylist = ['A','A','B','C','D','E','D']
cnt = Counter(mylist)
print [k for k, v in cnt.iteritems() if v > 1]
# ['A', 'D']

Leave a Comment