Skip to content
Advertisement

Remove duplicated considering one element from a list of lists python

I basically have a list of list like this:

JavaScript

I would like to remove the lists which contains duplicated values in index [0]. Also, i always need to have the list which its index [1] = ’20’, in this case ['1348562275', '20']. So my wanted list would be:

JavaScript

Does anyone have any idea how could i do it?

Advertisement

Answer

You could use a dictionary then convert it back to a list after processing:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement