title: Python why doesn't variable change after function?
body: <p>I'm doing a homework assignment for my CompSci class and this question came up:</p>
  
  <pre><code>x = 6
  def fun(x):
      y = x**2
      x = y
      return(x)
  fun(x)
  </code></pre>
  
  <p>When running this, the value that is printed out is 36, but when a run print(x), x is still 6.</p>
  
  <p>I would like to know why this happens; why x does not change?</p>
  
  <p>Thanks!</p>