+ 1

Matrix

A=[[1,5],[3,6]] B=[[3,1,-2],[4,0,7]] result=[[0,0,0],[0,0,0]] for i in range(len(A)): for j in range(len(B[0])): for k in range(len(B)): result[i][j] + A[i][k] * B[k][j] for r in result: print(r) this program can not run my computer.please give me a solution and how it does work please explained me

28th Feb 2018, 7:25 AM
Kawser Hamid
Kawser Hamid - avatar
1 Resposta
0
This line is not doing anything: result[i][j] + A[i][k] * B[k][j] If you want to assign a value to result[i][j], you should use the equal sign, like this: result[i][j] = A[i][k] * B[k][j]
1st Mar 2018, 2:25 AM
Pedro Maimere
Pedro Maimere - avatar