python-CSD-kursu/python-temel/foo.bar.nonlocal.py

13 lines
297 B
Python

def foo():
x = 10
def bar():
nonlocal x # foo'daki x
x = 20
def tar():
nonlocal x # bar'daki x
x = 30
tar()
bar()
print(x) # 30
foo()