title: python and assigning variable values in if statements
body: <p>I'm somewhat of a beginner in python and I swear I got a very similar program to what I'm doing right now to work. But, for some reason, I can't make it work. I was able to pinpoint my problem and created a fake program to play around with it. Here is what the program:</p>
  
  <pre><code>global heading
  global heading2
  global a
  
  heading=2
  a=2
  heading2=4
  
  def function ():
      if a==2:
          heading=heading2
          print 'yes'
          print heading
  
  function()       
  print heading
  </code></pre>
  
  <p>This is what appears:</p>
  
  <pre><code>yes
  4
  2
  </code></pre>
  
  <p>Why doesn't the heading variable heading keep the value 4? I tried putting return heading all over. Didn't work. I tried putting the variables in the parentheses of the function. Didn't work either... Do you know what I'm doing wrong?</p>