-1
Can anyone tell me what the problem is with this code ? (I’m a beginner).
import random
def mult():
num_l1, num_c1 = len(mat1), len(mat1[0])
num_l2, num_c2 = len(mat2), len(mat2[0])
for i in range(num_l1):
resp.append([])
for j in range(num_c2):
resp[i].append(0)
for m in range(num_c1):
resp[i][j] += mat1[i][m] * mat2[m][j]
return resp
mat1 = []
mat2 = []
resp = []
for i in range(3):
mat1.append([0] * 3)
for i in range(3):
mat2.append([0] * 3)
for i in range(len(mat1)):
for j in range(len(mat1)):
mat1[i][j] = random.randint(0, 9)
for i in range(len(mat1)):
for j in range(len(mat1)):
mat2[i][j] = random.randint(0, 9)
mult()
What’s the mistake? ...
– FourZeroFive
The code simply does not execute, or it appears that nothing happens
– Bruno Carvalho