python dictonary of dictonary

Solutions on MaxInterview for python dictonary of dictonary by the best coders in the world

showing results for - "python dictonary of dictonary"
Ricardo
23 Nov 2020
1from collections import defaultdict
2d = defaultdict(dict)
3d['dict1']['innerkey'] = 'value'
4
5>>> d  # currently a defaultdict type
6defaultdict(<type 'dict'>, {'dict1': {'innerkey': 'value'}})
7>>> dict(d)  # but is exactly like a normal dictionary.
8{'dict1': {'innerkey': 'value'}}