def red_packets(money, num): import random lst = [0, money * 100] + random.sample(range(1, money * 100,), num - 1) lst.sort() return ((lst[i + 1] - lst[i]) / 100 for i in range(num)) ret = red_packets(100, 10)