Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sum_matrix(matrix):
- tot = 0
- for x in matrix:
- if not isinstance(x, list):
- tot += x
- else:
- tot += sum_matrix(x)
- return tot
- print(sum_matrix([[1, 2, 3, 1, 4], [1, 2, 4, 1, 6]]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement