You can download this code by clicking the button below.
This code is now available for download.
The function is used to merge multiple iterable objects into one iterator. If the iterables are of uneven length, the specified value is used to fill in the shorter iterables.
Technology Stack : itertools (built-in library)
Code Type : Function
Code Difficulty : Intermediate
def zip_longest(*args, fillvalue=None):
"""
This function will return a zip object that aggregates elements from each of the iterables.
If the iterables are of uneven length, missing values are filled-in with the fillvalue.
"""
from itertools import zip_longest
return zip_longest(*args, fillvalue=fillvalue)