Suppose we have a dictionary:
some_dict = {
"first": 11111,
"second": {
"second_1": 22222,
"second_2": 232323,
"second_3": 99999
}
}
if I create a new variable a with value some_dict["second"], then it will be a reference:
ref = some_dict["second"]
Accordingly, if I change the value of the nested dictionary second in some_dict, then it will also change in ref:
some_dict["second"]["second_1"] = "not a second_1"
print(ref)
Output:
{'second_1': 'not a second_1', 'second_2': 232323, 'second_3': 99999}
How can I create the same reference, but not to a nested dictionary, but to a value, such as int or str?
Like this:
ref = some_dict["second"]["second_1"]
some_dict["second"]["second_1"] = "not a second_1"
print(ref)
Estimated output:
not a second_1