abcla - 2 months ago 23

Python Question

I have the following code

`l = len(time) #time is a 300 element list`

ll = len(sample) #sample has 3 sublists each with 300 elements

w, h = ll, l

Matrix = [[0 for x in range(w)] for y in range(h)]

for n in range(0,l):

for m in range(0,ll):

x=sample[m]

Matrix[m][n]= x

When I run the code to fill the matrix I get an error message saying "list index out of range" I put in a print statement to see where the error happens and when m=0 and n=3 the matrix goes out of index.

from what I understand on the fourth line of the code I initialize a 3X300 matrix so why does it go out of index at 0X3 ?