Merging Iterables with Fillvalue

  • Share this:

Code introduction


The function merges multiple iterable objects into an iterator. If one of the iterable objects is shorter, it fills the remaining positions with fillvalue.


Technology Stack : zip_longest, iterable objects, fillvalue

Code Type : Function

Code Difficulty : Intermediate


                
                    
def zip_longest(*args, fillvalue=None):
    zip_longest = zip_longest(*args, fillvalue=fillvalue)
    return [tuple(x) for x in zip_longest]