From 59bd5291a70b5ccc429cc1f563155bc5a4d8e120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20G=C3=B6r?= Date: Wed, 7 Jun 2023 09:00:26 +0300 Subject: [PATCH] nonlocal example --- python-temel/nonlocal.example.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 python-temel/nonlocal.example.py diff --git a/python-temel/nonlocal.example.py b/python-temel/nonlocal.example.py new file mode 100644 index 0000000..a84e3a2 --- /dev/null +++ b/python-temel/nonlocal.example.py @@ -0,0 +1,12 @@ +def foo(): + x = 10 + def bar(): + nonlocal x + print(x) + x += 1 + return bar + +f = foo() +f() +f() +f()