1>>> #You can simply call dict:
2>>> a
3defaultdict(<type 'list'>, {'1': ['b', 'a'], '3': ['b'], '2': ['a']})
4>>> dict(a)
5{'1': ['b', 'a'], '3': ['b'], '2': ['a']}
6
7# but remember that a defaultdict is a dict
8# (with some special behavior, check source):
9>>> isinstance(a, dict)
10True
1nums = [1, 2, 1, 1, 4, -4, 2, 2, 4, 2, 5, 7]
2dict_in_dict = defaultdict(dict)
3for i in range(0, len(nums), 3):
4 dict_in_dict[nums[i+1]][nums[i]] = -1*nums[i+2]
5dict(dict_in_dict)
6
7# result
8# {2: {1: -1, 2: -4}, 4: {1: 4}, 5: {2: -7}}