How can I find the duplicates in a Python list and create another list of the duplicates? The list only contains integers.
one-liner, for fun, and where a single statement is required.
(lambda iterable: reduce(lambda (uniq, dup), item: (uniq, dup | {item}) if item in uniq else (uniq | {item}, dup), iterable, (set(), set())))(some_iterable)