Issue
I have a method which requires being able to add multiple nested dictionaries at once.
For example:
mydict = {}
mydict['subdict']['subdict2'] = {'this': 'is what i want'}
How can I do this?
Solution
from collections import defaultdict
mydict = defaultdict(dict)
mydict['subdict']['subdict2'] = {'this': 'is what i want'}
Answered By - Andrey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.