I would like create an array of matrix in python, without use numpy. My array is a global variable:
file_data= []
And this is my matrix inside a function:
ncols = 4
nrows = 200000
matrix = [[0] * ncols for i in range(nrows)]
after I fill the matrix and try to assign the matrix at the array:
file_data[ff]=matrix
But I obtain this error:
file_data[ff]=matrix
IndexError: list assignment index out of range
Could someone help me?
1 Answer 1
Your file_data is an empty list, and therefore accessing file_data[ff] result in index out of range, whatever your ff is. To fix this, you can do file_data.append(matrix).
answered Feb 25, 2015 at 17:26
Ying Xiong
5,04810 gold badges39 silver badges80 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py