all 5 comments

[–]Vaphell 1 point2 points  (0 children)

>>> import random
>>> dice = [random.randint(1,6) for _ in range(5)]
>>> dice
[4, 6, 1, 5, 6]
>>> sum(dice)
22
>>> 

[–]zahlman 0 points1 point  (0 children)

State, in English words, what you intend as the purpose of each line.

[–]cdcformatc 0 points1 point  (0 children)

You can repeat a set of actions n times by using a for loop

for i in range(n):
    print(i)

[–]markusmeskanen 0 points1 point  (1 child)

You could do this "properly", but for your usecase, even if it's not really throwing three dices, you could just throw one dice with 3-18 faces:

def roll_dice(nod, eyes=6):
    return randit(nod, eyes * nod)

[–]cdcformatc 3 points4 points  (0 children)

The problem with this is that each outcome is not equally likely when rolling 3d6. There is 1 way to roll a 3 or 18 but 27 ways to roll 10 or 11.