L=[1,2,3,4,5]
sum=sum(L)
print(sum)
sum=0
num=0
L=[]
for i in range(1,101):
L.append(i*i)
将 变量sum的名称改成num即可
修改后
L=[1,2,3,4,5] num=sum(L) print(num) # sum=0 num=0 L=[] for i in range(1,101): L.append(i*i) num=sum(L) print(num)