如何将浮点数添加到列表中直到列表的长度等于 N 数?

How to add a float number into a list until the lenght of the list equals N number?

我必须创建一个程序,它询问浮点数列表的长度,然后它应该询问列表中的浮点数,最后它会打印这些数字的平均值。使用 Python 3.

我已经尝试使用 list.extend 并将带有赋值的数字添加到列表中并添加浮点输入。

numbersInTheList=int(input())
thoseNumbers=[]
while len(thoseNumbers)!=numbersInTheList:
    thoseNumbers=thoseNumbers + float(input())    
print(sum(thoseNumbers)/numbersInTheList)

我希望输出是列表中数字的平均值。

list.extend 用于用一个列表扩展另一个列表。在这种情况下,您希望 append 将单个值添加到现有列表。

numbersInTheList= int(input())
thoseNumbers = []
while len(thoseNumbers) != numbersInTheList:
    thoseNumbers.append(float(input()))
print(sum(thoseNumbers)/numbersInTheList)