I want to create a random list with diffrent combinations of elements in the list. The count of each element appearing in the final list should same.
For example
>>> set_sizes = [0, 3, 6, 12]
>>> target_list = random.choices(set_sizes, weights = [1, 1, 1, 1], k= 40)
>>> print (target_list.count(0), target_list.count(3), target_list.count(6), target_list.count(12))
8 10 12 10
Here I was expecting the count of all elements will be 10 since I give equal weights. But it is not same always. How can I modify the code to get the equal count for all elements ? Please help.
Aucun commentaire:
Enregistrer un commentaire