ID EN
Random

choices

Python 3.11

Return a k sized list of elements chosen from the population with replacement. If the population is empty, raises IndexError.

Syntax

PYTHON
random.choices(population, weights=None, *, cum_weights=None, k=1)

See Also

IndexError itertools.accumulate() TypeError float random() ValueError choices() choice()