Here's a simple implementation. First, sort the input list by weight, then enumerate, adding each item to the least full bucket.
def EvenlyDistribute(lst, n):
"""Distribute items in lst (tuples of (val, weight)) into n buckets"""
buckets = [[] for i in range(n)]
weights = [[0, i] for i in range(n)]
for item in sorted(lst, key=lambda x: x[1], reverse=True):
idx = weights[0][1]
buckets[idx].append(item)
weights[0][0] += item[1]
weights = sorted(weights)
return buckets
so
for i, v in enumerate(EvenlyDistribute(lst, 3)):
print(v)
returns
[['f', 100], ['h', 4]]
[['g', 90], ['a', 10]]
[['b', 40], ['d', 30], ['e', 20], ['c', 10]]