当前位置:首页 > python > 正文

python 输入一个列表

  • python
  • 2024-06-13 01:20:15
  • 3533
⓵Python创建一个一维列表,列表包含n个元素,n由键盘输入,列表元素由1-100随机?

代码是这样的,仅供参考:

arandomimportrandint
amount=int(input("随机数数量:"))
result=[randint(1,100)foriinrange(amount)]
print(result

输入:10

输出:[2,65,58,24,15,12,38,24,18,79]