How can I find the duplicates in a Python list and create another list of the duplicates? The list only contains integers.
Here's a neat and concise solution -
for x in set(li): li.remove(x) li = list(set(li))