def constrained_sum_sample_pos(n, total):
    """Return a randomly chosen list of n positive integers summing to total.
    Each such list is equally likely to occur."""
dividers = sorted(random.sample(range(1, total), n - 1))
return [(a - b) for a, b in zip(dividers + [total], [0] + dividers)]
Generate multiple random numbers to equal a value in python