I\'m trying to remove duplicates from a nested list only if the first 2 elements are the same, ignoring the third...
List:
L = [[\'el1\',\'el2\',\'va
If the order doesn't matter, you can use that same method but using a tuple of the first and second elements as the key:
dict(((x[0], x[1]), x) for x in L).values()
Or on Python 2.7 and higher:
{(x[0], x[1]): x for x in L}.values()
Instead of (x[0], x[1])
you can use tuple(x[:2])
, use whichever you find more readable.