From 374b8596cd237803fc4b47f101e05399a9509267 Mon Sep 17 00:00:00 2001 From: Kunal Nagar <160893021+CogitoKunal@users.noreply.github.com> Date: Sat, 26 Oct 2024 10:38:55 +0530 Subject: [PATCH] Create VariableScope.py --- .../VariableScope.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Program's_Contributed_By_Contributors/VariableScope.py diff --git a/Program's_Contributed_By_Contributors/VariableScope.py b/Program's_Contributed_By_Contributors/VariableScope.py new file mode 100644 index 0000000000..22387dda65 --- /dev/null +++ b/Program's_Contributed_By_Contributors/VariableScope.py @@ -0,0 +1,12 @@ + +x = 'Global x' + +def test(): + #global x + y = 'Local y' + x = 'Local x' + print(x +', '+ y) #prints 'Local x' and 'Local y' + +if __name__ == '__main__': + test() + print(x) #prints 'Global x' \ No newline at end of file