0
嘗試對每個相應列中的所有整數進行求和,將每個和 存儲在一個列表中。當我運行代碼時,它會產生一個類型錯誤=列表索引必須是整數或切片,而不是元組。2-D數組中的列總和。 TypeError:列表索引必須是整數或切片,而不是元組
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)