【发布时间】:2019-10-24 06:45:03
【问题描述】:
我对 python 还是很陌生,并且正在完成一项学校作业。该程序应该是一个循环,允许用户输入一系列数字,只要输入的数字为 0 或更大,这些数字就会继续运行。输入负数后,程序应创建所有输入数字的总和。非常感谢您的帮助,谢谢!
#This program calculates the sum of multiple numbers
#Initialize accumulator
total = 0
#Calculate the sum of numbers
while keep_going >= 0:
keep_going = int(input('Enter a number: '))
total += keep_going
print(total)
【问题讨论】:
标签: python python-3.7