Python homework

boffi at choices.random.py boffi at choices.random.py
Wed Dec 13 08:28:46 EST 2017


nick.martinez2 at aol.com (nick martinez2) writes:

> def rollDie(number):
>     rolls = [0] * 6
>     for i in range(0, number):
>         roll=int(random.randint(1,6))
>         rolls[roll - 1] += 1
>     return rolls

def rollDie(number):
    from random import choices
    return choices((1,2,3,4,5,6), k=number)

ps: sorry for the noise if someone else in this thread has already
highlighted the usefulness of `random.choices`



More information about the Python-list mailing list