I\'m trying to programmatically set a value in a dictionary, potentially nested, given a list of indices and a value.
So for example, let\'s say my list of indices i
Pyhton3 provide dotty_dict lib. see documentation https://dotty-dict.readthedocs.io/en/latest/ for more clarity
from dotty_dict import dotty dot = dotty() string = '.'.join(['person', 'address', 'city']) dot[string] = 'New York' print(dot)
output:
{'person': {'address': {'city': 'New York'}}}