python - 尝试使用用户输入作为起点从python 3范围内的列表中提取一定数量的数字
问题描述
x = input("How many numbers, between two and six? ")
print("You have selected, " + x + " numbers!")
import random # I would like to only print out the amount of numbers entered in the first line!!!
numbers = list(range(1,48)) # So if a user types six they get six random numbers and so on.
random.shuffle(numbers)
print(numbers)
解决方案
你试过这个吗
import random
x = input("How many numbers, between two and six? ")
print("You have selected, " + x + " numbers!")
li = [random.random() for x in range(int(x))]
print(li)
推荐阅读
- visual-studio-code - vscode:如果设置了断点,只打开调试选项卡?
- ssis - 如何使用 SSIS 从 CRM 中的 1000 个表中复制数据以进行访问?
- asp.net - 从网页中提取数据到 Excel 工作表
- javascript - 用户输入数据的 Javascript CLONE 元素
- android - 如何删除材质按钮中图标上的色调?
- azure - Azure Functions 在创建新密钥版本或密钥保管库过期时触发
- javascript - ajax请求删除功能的问题
- java - 执行 Maven 安装时构建 Maven 项目时出错
- java - java.io.FileOutputStream.write(int, boolean) 本机方法的源代码
- knex.js - Knex:在不接受绑定参数的原始查询中使值安全