Unique elements from a list
Published: Wednesday, Dec 26, 2007 Last modified: Thursday, Nov 14, 2024
There is a couple of new ways with 2.3: http://tinyurl.com/v72w Otherwise: def unique(self, list): d = {} for x in list: d[x] = 1 subset = d.keys() return subset Or list comp:
[x for x in data if data.count(x) == 1]
Or with sets.