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','value1'], ['el3','el4','value2'], ['el1','el2','value2'], ['el1','el5','value3']]
Would return:
L = [['el3','el4','value2'], ['el1','el2','value2'], ['el1','el5','value3']]
I found a simple way to do similar here:
dict((x[0], x) for x in L).values()
but this only works for the first element and not the first 2, but that is exactly what i want otherwise.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…