x = 5 def foo(): def bar(): global x x = 10 bar() print(x, end="#") foo() print(x, end="#")
5#5#
10#5#
5#10#
10#10#