Nested Lists and their index calls
Question: I was wondering how I would go about assigning a value to a specific index in
a list that is inside another list. For example:

For a list parentList

    
    
    for i in range(0,rows, 1):
            parentList[i] = []
            for j in range(0,cols,1):
                parentList[i[j]] = 0
    

Not sure if that is even the right syntax for assignment like this.

I know I can do .append, but what I need to do for my problem is create a
sparse matrix, so everything should be 0 except for the values that the user
specifies in the form `(row) (col) (value)`.

So I thought using the indexes of the lists would help with assignment. If
there is a better way, please let me know!

EDIT: This is an example of what is being done

input:

    
    
    1 2 2
    
    1 3 3
    
    2 1 4
    
    3 3 5
    
    0 0 0
    
    
    1 3 7
    
    2 2 8
    
    3 2 9
    
    3 3 6
    
    0 0 0
    

The first matrix in the input is:

    
    
    0 2 3
    
    4 0 0
    
    0 0 5
    

The second matrix is:

    
    
    0 0 7
    
    0 8 0
    
    0 9 6
    

Their product is:

    
    
    0 43 18
    
    0 0 28
    
    0 45 30
    

So the output should be:

    
    
    1 2 43
    
    1 3 18
    
    2 3 28
    
    3 2 45
    
    3 3 30
    
    0 0 0
    

I have to use a 1D array of linked lists to represent this in my code and all
input and output is done through the Python Shell.


Answer: It is easy to work with numpy arrays:

    
    
    import numpy as np
    a=np.empty((3,3))
    for i in range(a.shape[0]):
        for j in range(a.shape[1]):
            a[i][j]=0
    >>> a
    array([[ 0.,  0.,  0.],
           [ 0.,  0.,  0.],
           [ 0.,  0.,  0.]])
    

