programming-examples/python/Function/Python program of recursion list sum.py
2019-11-15 12:59:38 +01:00

10 lines
315 B
Python

def recursive_list_sum(data_list):
total = 0
for element in data_list:
if type(element) == type([]):
total = total + recursive_list_sum(element)
else:
total = total + element
return total
print( recursive_list_sum([1, 2, [3,4],[5,6]]))