【发布时间】:2015-03-01 20:39:43
【问题描述】:
我有一个想要循环 10 次的答案。
代码现在看起来像这样:
top = int(input("Please tell us the highest number in the range: "))
bottom = int(input("Tell us the lowest number in the range: "))
print("Batman picks the number",random.randint(bottom,top),"from the range between",bottom,"and",top)
这给我留下了答案:
请告诉我们该范围内的最大数字:100
告诉我们范围内的最小数字:10
蝙蝠侠从 10 到 100 之间选择了 57
现在我想让蝙蝠侠从范围中选择 10 个随机数。我是这样想的:
print("Batman picks the number",random.sample((bottom,top), 10),"from the range between",bottom,"and",top)
问题是我收到一条错误消息:
ValueError:样本大于总体
我必须填充什么?我需要另一个变量吗?
提前致谢。
问候托马斯
【问题讨论】: