I'd like to change a value in highly nested dictionary. I am at the stage when I've all needed paths in my list in given structure :
['Assets', 'Coop', 0, 'Room', 24, 'Id']
If I wanted to access the value of the dictionary manually I'd call it via
dict['Assets']['Coop'][0]['Room][24]['Id']
I've tried to achive my goal with simple recursion function however I'm still a beginner and actually am stuck
def set_in_dict(path, config, i, l):
if i == l-1:
config = 123123123123
else:
return set_in_dict(path,config[path[i]], i+1, l)
At this point my recursion function in this case reach the end of list, config become value of key : 'Id' and i change it to another value, however it changes only localy, globaly it's the same. I wonder if I can access and set value of my dict with some trick like conversion the list to the string in following format:
some_str = ['Assets']['Coop'][0]['Room][24]['Id']
dict[some_str] = 550