📜  数组作为python代码示例中的输入

📅  最后修改于: 2022-03-11 14:47:09.147000             🧑  作者: Mango

代码示例1
list1 = list() #empty list

num = input("How many elements do you want") #user tells the range(optional)

#iterating till user's range is reached
for i in range(int(num)): 
    n = input("Enter a value ")#asking for input of 1 value 
    list1.append(int(n))#adding that value to the list

print(list1)