You can download this code by clicking the button below.
This code is now available for download.
This function combines iterables together. If the iterables are of unequal lengths, it fills the shorter ones with a fillvalue.
Technology Stack : zip_longest
Code Type : Function
Code Difficulty : Intermediate
def zip_longest(*args, fillvalue=0):
zip_longest_generator = zip_longest(*args, fillvalue=fillvalue)
while True:
try:
yield [next(iter(x)) for x in zip_longest_generator]
except StopIteration:
break