尝试制作自定义骰子滚轮
它说"("非整数停止为randrange()")"
import random
sides = input("Sides")
custom = random.randrange(1, sides) #see here
请帮助我
问题在于自定义整数
选择整数但python不喜欢该范围
由人选择我应该做什么
答案 0 :(得分:1)
import random
sides = input("Sides")
if isinstance(sides, str) and sides.isdigit():
sides = int(sides)
# Ensure value to be greater than lower range i.e 1 else a traceback
if sides > 1:
custom = random.randrange(1, sides) #see here