You can download this code by clicking the button below.
This code is now available for download.
The function is used to aggregate elements from multiple iterable objects. If the length of the iterables is different, fillvalue is used to fill in missing values.
Technology Stack : itertools
Code Type : Iterator
Code Difficulty : Intermediate
def zip_longest(*iterables, fillvalue=None):
"Make an iterator that aggregates elements from each of the iterables.
The iterables must be of the same length or the shortest iterable is used.
Fillvalue is used for missing values if the iterables are of different lengths."
from itertools import zip_longest as zip_longest_from_itertools
return zip_longest_from_itertools(*iterables, fillvalue=fillvalue)