So I’m relatively new to Python and trying to figure out what’s the best way to keep only unique items in a list. My current implementation involves a Counter, dict and list comprehensions, but I’m not sure what may be faster.
Here’s an example of what I’ve tried:
l = ['a', 'b', 'a']
d = dict(Counter(l))
[key for key, val in d.items() if val == 1]
>>> ['b']
Also, this only works for strings and not ints and I’m not sure why.
Do you want only things that exist one time?
Or just a list of unique things?