Skip to content
Advertisement

Python – Unflatten dict

I have this multi-dimensional dict:

JavaScript

And written simple function to flatten that dict:

JavaScript

After call this function with dict a i get in result:

JavaScript

Now, after making few instructions on this flattened dict i need to build new, multi-dimensional dict from that flattened. Example:

JavaScript

The only problem I have is that i do not have a function unflatten :)
Can anyone help with this? I have no idea how to do it.

EDIT:

Another example:

JavaScript

Should be after unflatten:

JavaScript

And another:

JavaScript

To:

JavaScript

This greatly increases the difficulty of the task, i know. Thats why i had problem with this and found no solution in hours..

Advertisement

Answer

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