Skip to content
Advertisement

List of list of dicts values to list in python

The order of the resulted list is irrelevant, I need to add the elements afterwards.

JavaScript

Advertisement

Answer

That’s Pretty Simple all you Need is to just check the Type of the object

Then If it’s a list get the first index of it which is a dict

So for example if i have [{1,2,3}] It will convert it to Just {1,2,3}

Then Looping Through The values(not the keys) in the Dict and just adds it to a list

Whereas If it’s not a list then just add it to the list

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