Python, Python Programming, Coding, Web Developer, Code.
variable should be used instead of creating a new local variable. Here is an example that illustrates these rules written by PythonFlood: x = 1 def foo(): x = 2 print("Inside foo:", x) def bar(): global x x = 3 print("Inside bar:", x) foo() print("Outside foo:", x) bar() print("Outside bar:", x) In