You can download this code by clicking the button below.
This code is now available for download.
This function combines multiple iterable objects into a single iterable, padding with fillvalue if the iterables are of unequal length.
Technology Stack : itertools
Code Type : Function
Code Difficulty : Intermediate
def zip_longest(*args, fillvalue=()):
"""Combine several iterables into a single iterable with padding."""
from itertools import zip_longest as it_zip_longest
def my_zip_longest(*args, fillvalue=()):
iterator = it_zip_longest(*args, fillvalue=fillvalue)
for item in iterator:
yield item
return my_zip_longest(*args, fillvalue=fillvalue)