You can download this code by clicking the button below.
This code is now available for download.
This function takes multiple input iterables (elements of args) and combines them into a single iterable. If the iterables are of uneven length, missing values in the shorter iterables are filled with fillvalue.
Technology Stack : itertools
Code Type : Iterator processing
Code Difficulty : Intermediate
def zip_longest(*args, fillvalue=None):
"""
Zips the input iterables (elements of args) together into a single iterable.
If the iterables are of uneven length, missing values in the shorter
iterables are filled with fillvalue.
"""
from itertools import zip_longest as zip_longest_imp
return zip_longest_imp(*args, fillvalue=fillvalue)