title: Python: Keep changes on a variable made within a function
body: <p>I have a question on a fairly simple task in python, however, I didn't manage to find a solution. I would like to assign a new value to an already existing variable in python. However, the changes I am doing to the variable within the function don't stick to the variable.</p>
  
  <p>Here is a simplified example of my problem:</p>
  
  <pre><code>y = 1
  x = None
  
  def test(var):
  
      var = y
  
      return var 
  
  
  test(x)
  print(x)
  </code></pre>
  
  <p>The print simply returns none. So the changes I have done to the variable within the function are non permanent.</p>
  
  <p>How can I make the changes on the input-variable of the function permanent?</p>
  
  <p>Thanks in advance!</p>