How can I find the duplicates in a Python list and create another list of the duplicates? The list only contains integers.
When using toolz:
from toolz import frequencies, valfilter a = [1,2,2,3,4,5,4] >>> list(valfilter(lambda count: count > 1, frequencies(a)).keys()) [2,4]