You can download this code by clicking the button below.
This code is now available for download.
This function is similar to the built-in zip function, but it determines the length of the output tuple based on the shortest input sequence and fills in missing values with fillvalue.
Technology Stack : itertools
Code Type : Function
Code Difficulty : Intermediate
def zip_longest(*args, fillvalue=()):
"""
Like zip() but the shortest input sequence determines the length of the output
tuple, with missing values filled-in with fillvalue.
"""
from itertools import zip_longest as _zip_longest
return _zip_longest(*args, fillvalue=fillvalue)