Matrix Addition
Background
Matrix addition is the operation of adding two matrices by adding the corresponding entries together. Both matrices must have the same number of rows and columns.
Task
Write a function matrix_add(mat1, mat2) that computes the element-wise sum of two matrices.
Specifications
- The function takes two 2D lists
mat1andmat2. - It returns a new 2D list containing the sums.
- You may assume both matrices are always the same valid non-empty dimensions.
Constraints
- The input matrices will have identical sizes.
- Values can be integers or floats.
Example
Instructions
- Implement the logic in
solution.py. - Do not use
input()orprint(). - Test your solution locally before submitting.