nonlocal example 2

This commit is contained in:
Mert Gör ☭ 2023-06-04 17:17:20 +03:00
parent a5d6ac70f4
commit c6f5c580a3
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
1 changed files with 10 additions and 0 deletions

View File

@ -0,0 +1,10 @@
def foo():
x = 10
def bar():
def tar():
nonlocal x # foo'daki x
x = 20
tar()
bar()
print(x) # 20
foo()