n=int(input())
while n>0:
line = input().split()
m = int(line[0])
if m==0:
break
total = 0
while m > 0:
total += int(line[m])
m -= 1
print(total)
n-=1
如何改进并且达到题目要求呢
请使用上传代码块的方式上传代码,否则python代码不能正常运行
line = input().split()
total = []
while int(line[0])>0:
total_the = 0
for i in range(1,int(line[0])+1):
total_the += int(line[i])
total.append(total_the)
line = input().split()
for i in range(0,total.__len__()):
print(total[i])