error in python: list assignment index out of range
<p>I searched everywhere and even though there were a couple of questions and answers regarding this error I couldn't find a solution to fix my problem</p>

<p>I'm reading in from a file that contains letters and numbers and I'm populating my matrix depending on the values in that file.
ex: file
description of letters and numbers ... 
table:</p>

<pre><code>  a b c d 
a 1 2 5 6
b 5 6 3 4 
c 3 2 1 4 
d 2 4 6 8 
</code></pre>

<p>Here's the code</p>

<pre><code>matrix = [[0 for j in range(4)] for i in range(4)]
i = 0
j = 0

for line in file:
   for a in line:
      if is_number(a):
         matrix[i][j] = int(a)
         j+= 1
      if matrix.count(0) &lt; 2: #since matrix already populated with zeroes. it shouldn't have 
                               #many per program specifications, that's why I use this 
                               #conditional to increment i and reset j back to 0
         i += 1
         j = 0

file.close()
</code></pre>

<p>I don't understand why I keep getting that error. </p>
