I would like to build a multi-level dictionary such like:
A = {
'a': {
'A': {
'1': {},
'2': {},
},
'B': {
'1': {},
'2': {},
},
},
'b': {
'A': {
'1': {},
'2': {},
},
'B': {
'1': {},
'2': {},
},
},
}
My question is that whether it existed a function that I can build the above diction by:
D = function(['a', 'b'], ['A', 'B'], ['1', '2'], {})
This uses the copy function to allow you specify a different leaf node. Otherwise all the leaves will point to the same dictionary.