Discuss / Python / 各位,帮忙找错

各位,帮忙找错

Topic source

空瓶灵芝

#1 Created at ... [Delete] [Delete and Lock User]

sum = 0 name = [1,2,3,4,5,6,7,8,9,10] for x in name: sum = sum + x print(sum) SyntaxError: invalid syntax

妖刀-鬼

#2 Created at ... [Delete] [Delete and Lock User]

你把print那一行和sum那一行对齐试试

你这个没错啊 我复制粘贴过来可以运行啊

清霜_Lee

#4 Created at ... [Delete] [Delete and Lock User]

sum = 0 name = [1,2,3,4,5,6,7,8,9,10] for x in name: sum = sum + x

print(sum)

sum=sum+x 后面连空两行出现<<<再输入print(sum)

CliffVon

#5 Created at ... [Delete] [Delete and Lock User]

为什么连空两行就可以了?这是什么原因呢?


  • 1

Reply