Skip to content
Advertisement

Convert dictionary that has multiple list object into organised tuple format

I have a requirement where I am getting data from DB in a certain format (List of dictionary), but the next set of methods require data in a certain format (List of tuples). How to convert it.

The input format is

JavaScript

The output format which I need from this data is

JavaScript

Can someone please help me with finding the solution.

Advertisement

Answer

You can do it like this:

JavaScript

gives

JavaScript

You should before-hand replace None by '' in your input dictionary’s value’s lists.

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