Python 对于范围(b)变量中的i
对于每一笔筹集的资金,是否都要存储用户的输入Python 对于范围(b)变量中的i,python,for-loop,Python,For Loop,对于每一笔筹集的资金,是否都要存储用户的输入 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 = 制作一个列表以存储其中的值: b=int(input("Please enter how many people have collected mone
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 =
制作一个列表以存储其中的值:
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
使用以下命令:
`
b=int(输入(“请输入有多少人已收款:”)
总计=[]
对于范围(b)中的i:
a=int(输入(“请输入募集金额:”)
总计(a)
打印(“总计:,合计(总计))
`或者使用以下方法:
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: "))
这将在每次迭代中添加您的给定输入。PROTIP:用您正在使用的语言标记问题。