我是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
我怎样才能实现这一目标?
答案 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)