title: Scope of python variable in for loop
body: <p>Here's the Python code I'm having problems with:</p>
  <pre><code>for i in range (0,10):
      if i==5:
          i+=3
      print i
  </code></pre>
  <p>I expected the output to be:</p>
  <pre><code>0
  1
  2
  3
  4
  8
  9
  </code></pre>
  <p>However, the interpreter spits out:</p>
  <pre><code>0
  1
  2
  3
  4
  8
  6
  7
  8
  9
  </code></pre>
  <p>I know that a <code>for</code> loop creates a new scope for a variable in C, but have no idea about Python. Why does the value of <code>i</code> not change in the <code>for</code> loop in Python, and what's the remedy to it to get the expected output?</p>