You can download this code by clicking the button below.
This code is now available for download.
The zip_longest function is used to combine multiple iterable objects into an iterator. If the iterable objects are of uneven length, missing values are filled in with fillvalue.
Technology Stack : itertools
Code Type : Function
Code Difficulty : Intermediate
def zip_longest(*iterables, fillvalue=None):
"zip_longest(*iterables, fillvalue=<default>) -> zip object"
"Return an iterator that aggregates elements from each of the iterables.
The iterator returns pairs from the iterables. If the iterables are of uneven
length, missing values are filled-in with fillvalue. fillvalue defaults to
None."
from itertools import zip_longest
return zip_longest(*iterables, fillvalue=fillvalue)