Skip to content
Advertisement

Remove duplicate value on nested list python

I have a problem here when I want to remove duplicate in a list that has a nested list, how can I remove the duplicate value from list? What I got here from my script, it can remove a duplicate, but the nested list has a different result from what I expect.

This is my script:

JavaScript

Result:

JavaScript

Expected Result:

JavaScript

Advertisement

Answer

You need to initialize result = [] inside the loop:

JavaScript

If you don’t mind order:

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