from itertools import zip_longest
def combine_balanced(*lists):
"""
Combine multiple lists into one with balanced distribution.
Shorter lists are padded with None and skipped in the final output.
"""
combined = []
for group in zip_longest(*lists, fillvalue=None):
for item in group:
if item is not None: # Skip padding
combined.append(item)
return combined
list1 = [1, 2, 3]
list2 = ['A', 'B', 'C', 'D']
list3 = ['x', 'y']
# Combine with balanced distribution
result = combine_balanced(list1, list2, list3)
print("Balanced combined list:", result)
"""
run:
Balanced combined list: [1, 'A', 'x', 2, 'B', 'y', 3, 'C', 'D']
"""