Skip to content
Advertisement

Python 3.x Convert nested list of elements into nested dictionary with max recursion

I would like to convert a nested list like this:

JavaScript

to a nested dictionary like this:

JavaScript

with max recursion.

Possible variants of nested list:

JavaScript
JavaScript

INCORRECT variants:

JavaScript
JavaScript

Advertisement

Answer

Here is one approach (see comments in the code for details):

JavaScript

output:

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