小编Chr*_*n R的帖子

如何找到输入数字列表的总和

我对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)

python python-3.7

3
推荐指数
1
解决办法
82
查看次数

标签 统计

python ×1

python-3.7 ×1