Dev Helpers
← Back

Separate unique identifiers from ambiguous ones

Separate unique identifiers from ambiguous ones using Python lists and dictionaries.

Open this example in the interactive library

Source code

from collections import Counter
ids = ['A2', 'B1', 'A2', 'C9']
counts = Counter(ids)
print([key for key, n in counts.items() if n == 1])
print([key for key, n in counts.items() if n > 1])

Sample output

['B1', 'C9']
['A2']