Sum of Lists
ls = , , 8]], 9]有大佬知道怎么将list里面每个数字相加吗 ls = , , 8]], 9]
def deep_flatten(lst):
result = []
for i in lst:
if isinstance(i, list):
result.extend(deep_flatten(i))
else:
result.append(i)
return result
print(sum(deep_flatten(ls)))
页:
[1]