a=0
count=int(input("add the count:"))
data=[]
for i in range(count):
number = int(input())
a = a+number
data.append(number)
print(data)
print("The sum of the data is",a)
输入一个列表,求列表中的数的和
最新推荐文章于 2024-10-25 18:06:41 发布
该程序从用户处接收一个计数`count`,然后按此次数读取整数。每次读取的数字累加到变量`a`上,并将这些数字存储在列表`data`中。最后,程序打印出数字列表和它们的总和。

1112

被折叠的 条评论
为什么被折叠?



