Python3 函数计算多个列表元素之和
def sum_list_elements(*args): total_sum = 0 for lst in args: total_sum += sum(lst) return total_sum
a = [1] b = [2, 3] c = [] d = [5, 6, 7]
print(sum_list_elements(a, b, c, d)) # Output: 24
原文地址: https://www.cveoy.top/t/topic/nL11 著作权归作者所有。请勿转载和采集!