一、题目描述
计算数字列表的和。
输入:[1,2,3,4]
输出:10
二、代码实现
def sumofList(param_list):
total = 0
for item in param_list:
total += item
return total
list1 = [1, 2, 3, 4]
list2 = [17, 5, 3, 5]
print(sumofList(list1))
print(sumofList(list2))
三、运行结果
10
30
四、实用小tips
PyCharm,格式化代码快捷键:CTRL+Alt+L