Skip to content
Advertisement

Remove duplicates from a list of lists based on duplicate first elements [closed]

data is below

JavaScript

How to remove the duplicate elements in id.

Here 44, 17 id is repeating

Expected

JavaScript

Pseudo code

JavaScript

Advertisement

Answer

You can use a dict here:

JavaScript

The structure of unique_data will be like this:

JavaScript

To then get the unique items, we can use list(unique_data.values()), which gives us:

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