我不断收到 TypeError: unsupported operand type for +: 'int' and 'list' 所以我猜该数组没有被索引?请协助。
def main():
arr = [1, 2, 3, 4, 5]
length = len(arr)
maxAns = msa2(length, arr)
print maxAns
def msa2(length, *arr):
maxThus = 0
for i in range(0, length):
sum = 0
for j in range(i, length):
sum = sum + arr[j] # how to get value in index j
max(maxThus, sum)
return maxThus
if __name__ == '__main__':
main()