jeudi 14 février 2019

Generate random list with specefic items in python

I need to generate a random fix size list with specific integer numbers, and the sum of list items has to be fix. (For example, randomly use -2, 2, 3 to fill a list with size = 20 and the sum of list items has to be 60). In this example, size = 20, sum = 60, and numbers = [-2, 2, 3] are inputs.

Can I do this in python?

English is not my mother tongue, please excuse any errors on my question




Aucun commentaire:

Enregistrer un commentaire