You can download this code by clicking the button below.
This code is now available for download.
This function combines multiple iterable objects into an iterator. If an iterable runs out, it is filled with fillvalue.
Technology Stack : Generator, iterator
Code Type : Generator function
Code Difficulty : Intermediate
def zip_longest(*args, fillvalue=None):
zip_longest_args = args
iterator = iter(zip_longest_args)
while True:
yield (next(iterator, fillvalue) for _ in zip_longest_args)