I have a form dictionary:
d = {123:{2:1,3:1}, 124:{3:1}, 125:{2:1},126:{1:1}}
So, let's look at the keys of the second degree.
123--> 2,3 124--> 3 125--> 2 126--> 1
Thus, the total number of unique second-order keys:
1,2,3
Now I want to change this dict as
d = {123:{1:0,2:1,3:1}, 124:{1:0,2:0,3:1}, 125:{1:0,2:1,3:0},126:{1:1,2:0,3:0}}
Thus, basically all second-order keys are missing from a particular 2d dict .. add this key with a value of 0.
What is the pythonic way to do this? Thanks
source share