You can download this code by clicking the button below.
This code is now available for download.
The function is used to combine multiple iterable objects. If the iterable objects have different lengths, it fills in the missing values with fillvalue.
Technology Stack : itertools
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 fillvalue.
# Uses itertools.zip_longest from the Python standard library.
import itertools
return itertools.zip_longest(*args, fillvalue=fillvalue)