title: A small question about the change() function,how to understand the process about it?
body: <p>I am learning the basic usage of python,and I'm confusing about how the variable runs in a practice question. Here are the code below:</p>
  
  <pre><code>x = 1
  def change(a):
    a = x + 1
    print(x)
  change(x) 
  
  x = 1
  def change(a)
    x = x + 1
    print(x)
  change(x) 
  </code></pre>
  
  <p>This is how I think the process:
  in the first code:change(x) means: x = x + 1  -  print （x）  -  output:2
  but in fact the result is 1.So the real process is: x(symbol in the function) = x(global variable) + 1, print(x), this x is the global variable.
  is that right?</p>
  
  <p>in the second code,I think still the output should be 2,but it shows me that UnboundLocalError: local variable 'x' referenced before assignment
  so in the python,we can't use function to change the global variable?</p>