简体   繁体   English

如何将整数输入到数字序列数组中?

[英]How can you make an integer input to an array of number sequences?

eg.例如。

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

I need to make a system that can show values of the array itself and also assigning the numbers to the array index我需要制作一个可以显示数组本身的值并将数字分配给数组索引的系统

You can do something like : declare a list and go on appending to the list您可以执行以下操作:声明一个列表并继续添加到列表中

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 你如何在 Python 中输入转义序列? - How do you input escape sequences in Python? 如何使 function 的返回类型根据该序列类型将序列作为输入? - How can I make the return-type of a function taking a sequence as input dependent on that sequences types? 如何检查输入是否为数字,然后将其转换为 integer? - How can I check if an input is a number and then turn it into an integer? 您如何确定先前输入中整数的输入数量? 骰子游戏 - How do you determine the number of inputs from an integer in a prior input? Dice game 为什么不能将此数字设为整数? - Why can't I make this number an integer? 如果输入在Python中无效,如何再次显示程序提示? - How can you make a program prompt again if the input is invalid in Python? 如何创建一个 if 语句来检查输入是否为 str/int - How can you make an if statement that checks if input is a str/int 我如何从输入中给出一个数字并在 python 中制作一个三角形 - how can i give a number from input and make a triangle in python 创建模式以检测序列的出现,以便您可以限制在哪些情况下替换输入字符串中检测到的子字符串 - Create patterns to detect the occurrence of sequences so that you can restrict in which cases to replace the detected substrings in the input string 您可以使用输入接受整数和字符串吗? - Can you use input to accept both an integer and a string?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM