【发布时间】:2019-09-22 20:50:17
【问题描述】:
我必须创建一个程序,它询问浮点数列表的长度,然后它应该询问列表中的浮点数,最后它会打印这些数字的平均值。使用 Python 3。
我已尝试使用 list.extend 并将带有分配的数字添加到列表中并添加浮点输入。
numbersInTheList=int(input())
thoseNumbers=[]
while len(thoseNumbers)!=numbersInTheList:
thoseNumbers=thoseNumbers + float(input())
print(sum(thoseNumbers)/numbersInTheList)
我希望输出是列表中数字的平均值。
【问题讨论】:
标签: python-3.x list add items