title: How does the Python's range function work?
body: <p>If I write</p>
  
  <pre><code>for i in range(5):
        print i
  </code></pre>
  
  <p>Then it gives 0, 1, 2, 3, 4<br>
  Does that mean Python assigned 0, 1, 2, 3, 4 to i at the same time?<br>
  However if I wrote:</p>
  
  <pre><code>for i in range(5):
        a=i+1
  </code></pre>
  
  <p>Then I call a, it only gives 5<br>
  But if I add ''print a'' it gives 1, 2, 3, 4, 5<br>
  So my question is what is the difference here?<br>
  Is i a string or a list or something else?  </p>
  
  <p>Or maybe can anyone help me to sort out:</p>
  
  <pre><code>for l in range(5):
      #vs,fs,rs are all m*n matrixs,got initial values in,i.e vs[0],fs[0],rs[0] are known
      #want use this foor loop to update them
      vs[l+1]=vs[l]+fs[l]
      fs[l+1]=((rs[l]-re[l])
      rs[l+1]=rs[l]+vs[l]
  #then this code gives vs,fs,rs
  </code></pre>
  
  <p>If I run this kind of code, then I will get the answer only when l=5<br>
  How can I make them start looping?  </p>
  
  <p>i.e l=0 got values for vs[1],fs[1],rs[1],<br>
  then l=1 got values for vs[2],rs[2],fs[2]......and so on.<br>
  But python gives different arrays of fs,vs,rs, correspond to different value of l  </p>
  
  <p>How can I make them one piece?    </p>