Skip to content

Instantly share code, notes, and snippets.

@MeherajUlMahmmud
Created May 2, 2021 13:03
Show Gist options
  • Save MeherajUlMahmmud/22453569c1d869de15c91581bbef0eec to your computer and use it in GitHub Desktop.
Save MeherajUlMahmmud/22453569c1d869de15c91581bbef0eec to your computer and use it in GitHub Desktop.
def multiply(mat1, mat2):
row1 = len(mat1)
col1 = len(mat1[0])
rows2 = len(mat2)
col2 = len(mat2[0])
result = zeros(row1, col2)
if (len(mat1[0]) != len(mat2)):
print('The two matrices cannot be multiplied')
return
else:
for i in range(row1):
for j in range(col2):
productList = [mat1[i][k] * mat2[k][j] for k in range(col1)]
result[i][j] = sum(productList)
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment