我的家庭作业是用“For循环”计算用户输入的一系列数字的总和,但我似乎无法成功地将输入的数字相加。在
我尝试过打印保存循环重复的数字量的变量,并使用“1+2+3+4+5”之类的方法,但它要么每次代码循环都打印,要么打印“15”。代码如下:
listo = (1,2,3,4,5)
for num in range(len(listo)) :
float(input("Enter a number: "))
krab = #This is where I'm struggling, as I don't know how to add the inputted numbers.
print "Your total sum is" , krab
输出应该是每次循环的总和,所以如果输入的数字是5到10,程序应该打印“35”。在
相关问题 更多 >
编程相关推荐