x = 4 def foo(): x = x + 1 # Creates a local copy of x foo() print x # Outputs '4'
def foo(): global x x = x + 1 # Modifies the global x