python - 如何将整数输入到数字序列数组?
问题描述
例如。
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
我需要制作一个可以显示数组本身的值并将数字分配给数组索引的系统
解决方案
您可以执行以下操作:声明一个列表并继续附加到列表
array = []
x = input("enter a number : ") # example; 10
array.append(x)
print(*array , sep = ", ")
推荐阅读
- java - 在netbeans中编译期间的Maven错误
- javascript - 从另一个页面获取元素
- java - 正则表达式用于在不被单引号或双引号包围时使用空格和特殊字符分割字符串
- php - 用户 'database username'@'%' 拒绝访问数据库 'information_schema'
- c++ - 如果可能,总是更喜欢 std::string(ptr, size) 到 std::string(first, last) ?
- spring - RestEasy 端点抛出 java.lang.NoSuchMethodError: org.codehaus.jackson.map.ObjectMapper.constructType
- node.js - 使用 Puppeteer 捕获表格元素并与之交互
- css - 如何在 django 中有条件地向元素添加 css 类?
- python - 在 _fields_ 中混合 ctypes 和 python 类
- java - 按 indexof 数组排序类列表