I'm looping through a data set, and updating a dictionary as needed. As a precursor to the dictionary update, I have a "default" dictionary "template" like so:
databody_item = {'name': 'Kermit',
'interests': {
'test1':True,
},
}
I want to update the interests dictionary inside of the databody_item dictionary, so I run:
databody_item.update({'interests':{'test2':True}})
This however cleared the entire interests dict, leaving me with this:
{'interests': {'test2': True}, 'name': 'Kermit'}
However, I need the dictionary to be updated like this:
{'interests': {'test1': True, 'test2': True}, 'name': 'Kermit'}