首页 > 解决方案 > 如何将整数输入到数字序列数组?

问题描述

例如。

x = input("enter a number : ") # example; 5

# code to make an array of numbers

print("the array value of the number is : ") # output is 1, 2, 3, 4, 5

我需要制作一个可以显示数组本身的值并将数字分配给数组索引的系统

标签: python

解决方案


您可以执行以下操作:声明一个列表并继续附加到列表

array = []
x = input("enter a number : ") # example; 10
array.append(x)
print(*array , sep = ", ") 

推荐阅读