def constrained_sum_sample_nonneg(n, total):
    """Return a randomly chosen list of n nonnegative integers summing to total.
    Each such list is equally likely to occur."""
return [(x - 1) for x in constrained_sum_sample_pos(n, total + n)]
Generate multiple random numbers to equal a value in python