I have a dict struct such like this:
a = {'1' : {}, '2' : {}}
b = {'3' : 3, '4' : 4}
I want to have the following format:
a = {'1' : { '3' : 3 }, '2' : { '4' : 4 } }
I have tried many times, but I always get lost, could anybody help me?
I have a dict struct such like this:
a = {'1' : {}, '2' : {}}
b = {'3' : 3, '4' : 4}
I want to have the following format:
a = {'1' : { '3' : 3 }, '2' : { '4' : 4 } }
I have tried many times, but I always get lost, could anybody help me?
c = {i:{j:k} for i, (j, k) in zip(a.keys(), b.items())}
>>> c
{'2': {'3': 3}, '1': {'4': 4}}
There is no order in a dictionnary so you can't ensure that {3:3} or {4:4} is the value of key '1' or "2'
This works but what's the use case? Seems like there probably is a more elegant solution.
a = {i:{j:k} for i,(j,k) in zip(a.keys(),b.items())}