I have a list in Python: [1, 2, 3, 4, 5, 1, 6, 7, 8, 9, 1, 4, 7].
I need to create two separate lists from this:
[2, 3, 5, 6, 8, 9] which contains elements that appear only once in the original list.
[1, 4, 7] which contains elements that appear multiple times in the original list.
Could anyone help me with a way to remove the duplicates from the original list while preserving these unique and duplicate elements in their respective lists?
from collections import Counter
lst = [1, 2, 3, 4, 5, 1, 6, 7, 8, 9, 1, 4, 7]
counts = Counter(lst)
singles = [k for k, v in counts.items() if v == 1]
multiples = [k for k, v in counts.items() if v > 1]
another_way = list(filter(lambda k: counts[k] == 1, counts))