Consider that you have a nested dictionary as the following:
{
"text": "hi",
"next": {
"text": "hi",
"next": {
"text": "hi",
}
}
}
Now I want to change the last node to {"text": "bye"}
, so that my end result is as follows:
{
"text": "hi",
"next": {
"text": "hi",
"next": {
"text": "bye",
}
}
}
Remember that there can be thousands of nodes but I want to modify just the last node. How can I do it?