随机数生成器作为骰子

时间:2013-12-10 18:40:56

标签: python dice

我正在尝试为3个不同的骰子创建一个随机数生成器,但我无法找到继续使用的解决方案。

import random

question = int(input("What sided dice woud you like to roll? 4, 6 or 12?: "))

if question == 4:
    random_number = 

1 个答案:

答案 0 :(得分:1)

您想要使用:random.randint(Min,Max)

import random
dice = int(raw_input("What sided dice woud you like to roll? 4, 6 or 12?"))
while dice !=0:
    print random.randint(1,dice)
    dice = int(raw_input("What sided dice woud you like to roll? 4, 6 or 12? press 0 to stop."))