I am trying to update values ββin a nested dictionary without overwriting previous entries when the key already exists. For example, I have a dictionary:
myDict = {} myDict["myKey"] = { "nestedDictKey1" : aValue }
giving
print myDict >> { "myKey" : { "nestedDictKey1" : aValue }}
Now I want to add another entry under "myKey"
myDict["myKey"] = { "nestedDictKey2" : anotherValue }}
This will return:
print myDict >> { "myKey" : { "nestedDictKey2" : anotherValue }}
But I want:
print myDict >> { "myKey" : { "nestedDictKey1" : aValue , "nestedDictKey2" : anotherValue }}
Is there a way to update or add "myKey" with new values ββwithout overwriting the previous ones?
source share