I was wondering how I would take a list, ex a = [1, 5, 2, 5, 1], and have it filter out unique values, so that it only returns a number that only occurred once in the list. So it would give me a=[2] as a result.
I was able to figure out how to filter out duplicates, now how would I get rid of the duplicates?
No need for the straight answer, just a little tip or hint is welcome 🙂
I was able to find this on stackoverflow. It does what I want, but I do not understand the code though, can someone break it down for me?
d = {}
for i in l: d[i] = d.has_key(i)
[k for k in d.keys() if not d[k]]
1 Answer