I would like to add multiple values to a dictonary key in python. The value is again a dict with some paraments changing..
I have written the following code but that seem to overwrite. any ways to do it effectively?
from collections import defaultdict
node = 'node 1'
d = defaultdict(dict)
d[node] = {'interface':{'Eth1/48':'10.10.10.1'}} --> Here Eth1/48 is dynamically populated.
d[node] = {'interface':{'Eth1/47':'10.10.11.1'}} --> here Eth1/47 is again dynamically populated.
>>> d
defaultdict(<class 'dict'>, {'node 1': {'interface': {'Eth1/47': '10.10.11.1'}}})
I want the output something like this:
{'node 1':{'interface': {'Eth1/48':'10.10.10.1'}
{'Eth1/47':'10.10.11.1'}