How do I create a dictionary in python whose values are also a dictionary? Basically, my question is that I have this list of lists:
['http://a11y.in/a11ypi/idea/a11y_firesafety.html',
['lang:hi', 'lang:kn'],
['a11y_firesafety.html:div1', 'a11y_firesafety.html:div1'],
['hi', 'kn']
]
and I want to convert it to:
{'http://a11y.in/a11ypi/idea/a11y_firesafety.html':
{'lang:hi':
{'lang:kn':
{'a11y_firesafety.html:div1':
{'a11y_firesafety.html:div1': {'hi', 'kn'}}}}}}
Can someone suggest me a way to do it? I tried using multidimensional dictionaries but they were of no use. Please help!
Try this:
This will work for a flat list as follows:
I realize that doesn’t answer (all) of your question, since you have nested lists. But then again, it should get you most of the way 🙂