Python接受可变数量的输入?

Python接受可变数量的输入?,python,input,Python,Input,有没有办法让python根据用户这样说的内容获取大量输入 x = input("how many numbers do you have?") 如果x=5,程序会要求1号,2号,3号,等等 这可能吗 amount = int(input("Enter the amount of numbers that you have: ")) numbers = [] for i in range(amount): new = input('Enter number {}: '.format(i

有没有办法让python根据用户这样说的内容获取大量输入

x = input("how many numbers do you have?")
如果x=5,程序会要求1号,2号,3号,等等

这可能吗

amount = int(input("Enter the amount of numbers that you have: "))

numbers = []
for i in range(amount):
    new = input('Enter number {}: '.format(i+1))
    numbers.append(new)

print(numbers)

您可能应该阅读一下Python中的循环。

您要查找的关键字是“循环”Yes。只需输入该数字,并将其用作循环变量。我会执行
'enternumber{}:'。format(I+1)
Noone从str.format显示爱:c@Sabyasachi你说得对,看起来干净多了。编辑。