在python

时间:2017-03-26 04:53:05

标签: python list input

我是python的新手,我用这个代码从用户那里得到一个数字。我不确定如何,但我想让输入框等于第一行代码中的数字。

x = input("How many video games do you own: ")
list1 =[x]

for games in list1:
    name1=input("Enter game1: ")

我想要发生什么

How many video games do you own: 4
Video game 1 = 1
Video game 2 = 2
Video game 3 = 3
video Game 4 = 5

[1,2,3,4]

没有错误,只打印game1

我怎样才能实现这一目标?

1 个答案:

答案 0 :(得分:1)

x = input("How many video games do you own: ")
list1 = []

for games in range(int(x)):
    name1 = input("Enter game1: ")
    list1.append(name1)

print(list1)