无论如何,是否存在每个筹集资金的用户输入总数?
b=int(input("Please enter how many people have collected money: "))
for i in range(b):
a=int(input("Please enter the amount raised: "))
total =
答案 0 :(得分:0)
列出一个列表来存储值:
b=int(input("Please enter how many people have collected money: "))
total = [0]*b
for i in range(b):
a=int(input("Please enter the amount raised: "))
total[i] = a
答案 1 :(得分:0)
使用此: ` b = int(输入("请输入有多少人收钱:"))
总= []
对于范围(b)中的i,: a = int(输入("请输入筹集的金额:")) total.append(a) 打印("总计:",总和(总计)) `
答案 2 :(得分:0)
或者使用它:
b=int(input("Please enter how many people have collected money: "))
total=0
for i in range(b):
total+=int(input("Please enter the amount raised: "))
这会在每次迭代时在total
添加您的给定输入。