number generator

cesco fd.calabrese at gmail.com
Fri Mar 9 09:44:01 EST 2007


I have to generate a list of N random numbers (integer) whose sum is
equal to M. If, for example, I have to generate 5 random numbers whose
sum is 50 a possible solution could be [3, 11, 7, 22, 7]. Is there a
simple pattern or function in Python to accomplish that?

Thanks and regards
Francesco




More information about the Python-list mailing list