def layer1(): parentvariable='Info' print(parentvariable) def layer2(): nonlocal parentvariable parentvariable='New Info' layer2() print(parentvariable) layer1()Note, I am not sure exactly why you want this and thus there might be better approach overall to what you try to do. It's very likely a XY problem.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs