'Python Matrix Multiplication integers using for loops

from numpy import linalg
from numpy import matmul



A = [[1,2],[2,3]]
b = [[5],[2]
Ab = [] 

nrows = 2
ncols = 2
for i in range(0,nrows):
    sum = 0
    for j in range(0,ncols):
        sum = sum + A[i][j] * b[j][0]
    Ab[?] = ?  

print(Ab)

exit()

I am not sure what to put in place of the questions marks " Ab[?] = ?" I tried "Ab[i] = sum" but that does not seem to be working. I need this code to print the results of the multiplied matrices listed in A and b. Is the line "sum = sum + A[i][j] * b[j][0]" right?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source