Merging Iterables with Fillvalue using zip_longest

  • Share this:

Code introduction


The function merges multiple iterable objects into an iterator. If an iterable runs out of items, it is filled with the fillvalue.


Technology Stack : itertools

Code Type : Function

Code Difficulty : Intermediate


                
                    
def zip_longest(*iterables, fillvalue=None):
    from itertools import zip_longest as zip_longest_from_itertools

    return zip_longest_from_itertools(*iterables, fillvalue=fillvalue)                
              
Tags: