Matrix Multiplication
Background
Matrix multiplication involves computing the dot product of rows from the first matrix and columns from the second. The number of columns in the first matrix must match the number of rows in the second.
Task
Write a function matrix_mul(mat1, mat2) that multiplies two matrices.
Specifications
- The function takes two 2D lists
mat1andmat2. - It should return their matrix product as a new 2D list.
Constraints
- The matrices will have compatible dimensions: $M \times N$ and $N \times P$.
- Matrices will not be empty.
Example
Instructions
- Implement the logic in
solution.py. - Do not use
input()orprint(). - Test your solution locally before submitting.