0

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?

0

1 Answer 1

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.