我对python还是很陌生,正在处理学校作业,这应该是一个循环,允许用户输入一系列数字,只要输入的数字为0或更大,该数字就会持续下去。输入负数后,程序应创建所有输入数字的总和。任何帮助,不胜感激,谢谢!
#This program calculates the sum of multiple numbers
#Variable to control the loop
keep_going = >-0
#Initialize accumulator
total = 0
#Calculate the sum of numbers
while keep_going == 0:
int(input('Enter a number: '))
keep_going = int(input('Enter a number: '))
Run Code Online (Sandbox Code Playgroud)