import numpy as np def for_loop_matrix_multiplication(A, B): """Fifth and final version of a for loop matrix multiplication.""" new_matrix = [] for row in A: new_row = [] for col in zip(*B): new_row.append(sum([x*y for (x, y) in zip(row, col)])) new_matrix.append(new_row) return new_matrix if __name__ == '__main__': A = [[1, 2, 3], [4, 5, 6]] B = [[7, 8], [9, 10], [11, 12]] print(for_loop_matrix_multiplication(A, B)) # The result should be: [[58, 64], [139, 154]] # You can check this by doing: np.matmul(A, B)