Possible Duplicate:
Matrix Multiplication in python?
I already wrote a program can multiply two matrices. But these code doesn’t work if two matrix have different columns(wrong answer).
C = [[4,1,9], [6,2,8], [7,3,5]]
D = [[2,9], [5,2], [1,0]]
M=[]
for i in range(len(C)):
Z.append([])
for j in range(len(D[0])):
Z[i].append(0)
for k in range(len(D[0])):
M[i][j]+=C[i][k]*D[k][j]
print (M)
Here is other version using numpy
Well I was just putting a little code, but here you are the whole code: