title: Python error: IndexError: list assignment index out of range
body: <pre><code>a=[]
  a.append(3)
  a.append(7)
  
  for j in range(2,23480):
      a[j]=a[j-2]+(j+2)*(j+3)/2
  </code></pre>
  
  <p>When I write this code, it gives an error like this:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:/Python26/tcount2.py", line 6, in &lt;module&gt;
      a[j]=a[j-2]+(j+2)*(j+3)/2
  IndexError: list assignment index out of range
  </code></pre>
  
  <p>May I know why and how to debug it?</p>