Combining Iterables with FillValue

  • Share this:

Code introduction


This function is used to combine multiple iterable objects into an iterator. If one of the iterable objects is shorter than the others, it fills in the missing positions with fillvalue.


Technology Stack : itertools

Code Type : Function

Code Difficulty : Intermediate


                
                    
def zip_longest(*args, fillvalue=None):
    from itertools import zip_longest

    def helper(iterables):
        return zip_longest(*iterables, fillvalue=fillvalue)

    return helper                
              
Tags: