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?
CodePudding user response:
from collections import defaultdict
mydict = defaultdict(dict)
mydict['subdict']['subdict2'] = {'this': 'is what i want'}