nonlocal example

This commit is contained in:
Mert Gör 🇹🇷 2023-06-07 09:00:26 +03:00
parent f27246a281
commit 59bd5291a7
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9

View File

@ -0,0 +1,12 @@
def foo():
x = 10
def bar():
nonlocal x
print(x)
x += 1
return bar
f = foo()
f()
f()
f()