You can download this code by clicking the button below.
This code is now available for download.
The function is similar to the built-in zip function, but it returns an iterator where the length of the output is determined by the longest input iterable. If an iterable is shorter, missing values are filled with the value specified by the fillvalue argument.
Technology Stack : itertools
Code Type : Function
Code Difficulty : Intermediate
def zip_longest(*args, fillvalue=None):
"""
Like zip() but the output list will be as long as the longest input iterable.
"""
from itertools import zip_longest as _zip_longest
return _zip_longest(*args, fillvalue=fillvalue)