error nonlocal example

This commit is contained in:
Mert Gör 🇹🇷 2023-06-04 21:04:56 +03:00
parent c8bb84641a
commit d13ec5b03b
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,11 @@
x = 10
def foo():
global x
x = 20
def bar():
#nonlocal x # error, x üst fonksiyonda global
x = 30
bar()
foo()
print(x)

View File

@ -0,0 +1,11 @@
x = 10
def foo():
global x
x = 20
def bar():
nonlocal x # error, x üst fonksiyonda global
x = 30
bar()
foo()
print(x)