Eliminate Duplicates of a List (Python)
I have a list of lists and need to eliminate all lists that have the same 3rd element, and save 1.
could turn into:
I've attempted a solution that eliminates all lists that have the same 2nd index using lambda, but I don't know how to save one of each element like set() does--I just get:
Python sets should still work for you:
>>> seen = set() >>> result =  >>> for s in x: e = s if e not in seen: result.append(s) seen.add(e) >>> result [[1, 2, 3], [2, 4, 6], [8, 5, 9]]