【发布时间】:2016-12-14 22:18:50
【问题描述】:
尝试对每一列中的所有整数求和,存储每个总和 在一个列表中。当我运行代码时,它会产生一个类型错误 = 列表索引必须是整数或切片,而不是元组。
array = [[3, 5, 7, 9]
[2, 7, 3, 5],
[1, 2, 6, 3],
[6, 9, 5, 3]]
column_sum = []
total = 0
i = 0
for row in aList:
total = total + row[i]
column_sum.append(total)
total = 0
i = i + 1
print(column_sum)
【问题讨论】:
标签: python-3.x