Ad

Roll the Dice

Get dice roll results from multiple dice of the same type.

#Dice notation
Dice are entered as strings such as "2d6" where the first number indicates the quantity of dice thrown and the last number indicates the number of sides on the dice. It is assumed that all dice are numbered with one side for each number between 1 and the number of sides.

e.g. "2d6" means 2 dice are thrown. Each dice is a 6 sided dice with values 1-6.

#Expected results
Return a list of results from all dice thrown.

e.g. 2d6 should have results such as [2,5] or [1,6] or [3,3]
e.g. 3d500 (after setting random.seed(444) should result in [159,148,7]

import random
def roll_dice(dice_text:str):
    
    #this returns the correct value for roll_dice("2d1000")
    return [random.randint(1,1000), random.randint(1,1000)]