I want to sum numbers in multidimentional array using recursion in Python:
tab = [7, 5, [3, 6, [2]], 7, [1, [2, 3, [4]], 9, 2], 4]
I have tried few things, for example this:
sum(map(sum, tab))
It works for simple arrays, e.g. [[1, 2], [3, 4]], but it doesn't work for the one on top. I get this error:
TypeError: 'int' object is not iterable
Any ideas please?