Consider this dictionary shown below:
"Title": {
"Label-1": {
"sublabel-1": {
"item1": {},
"item2": {}
},
"sublabel-2": {
"item3": {},
"item4": {},
"item5": {}
}
}
"Label-2": {
"sublabel-1": {
"item6": {},
"item7": {},
"item8": {},
}
}
}
Here is a dictionary to modify some key-value pairs as shown below.
values_to_add={item1:a,item2:b}
The goal is to add values a and b to the respective keys in the dictionary.
For reference, I read the following posts:
1.First Reference: (The difference is that I just have the key-value pair to modify and not the detailed trail upto the key-value pair as given in the update variable.)
2.Second Reference: (Unfortunately, no follow up on the question.)
Some additional points:
Level and depth of dictionary may vary. The main focus would be to add values to the innermost keys for any sublabel most of the times.(in this case item1 and item2)
Using python 2 to manipulate the dictionary.
I am currently trying to create a program to work it out. Hopefully looking to get some insights on different approaches to the problem and learn something new.