Edit nested dictionary with limited information
- by user1082764
How can i change the 'space' of 'albert' if i dont know if he is a donkey or a zebra?
self.object_attr = {'donkey': {
'name': 'roger', 'zone': 'forrest', 'space': [0, 0]}{
'name': 'albert', 'zone': 'forrest', 'space': [1, 1]}
'zebra': {
'name': 'roger', 'zone': 'forrest', 'space': [0, 0]}{
'name': 'albert', 'zone': 'forrest', 'space': [1, 1]}}
This can search for albert in the dictionary but how can i change his location?
for i in self.object_attr
for j in self.object_attr[x][name]
if j == 'albert'