How can I find the duplicates in a Python list and create another list of the duplicates? The list only contains integers.
>>> l = [1,2,3,4,4,5,5,6,1] >>> set([x for x in l if l.count(x) > 1]) set([1, 4, 5])