dict from dict python code example
Example 1: dict of dict python
nested_dict = { 'dictA': {'key_1': 'value_1'},
'dictB': {'key_2': 'value_2'}}
Example 2: make nested dict from two dict
data = [
[14, 77766, [2, 2]],
[15, 77766, [1, 2]],
[70, 88866, [1, 5]],
[71, 88866, [2, 5]],
[72, 88866, [5, 5]],
[73, 88866, [4, 5]],
[74, 88866, [3, 5]],
[79, 99966, [1, 2]],
[80, 99966, [2, 2]],
]
c = {}
for key, id_, (value, _) in data:
c.setdefault(id_, {})[key] = value
print(c)