Extended Zip Function with Fillvalue

  • Share this:

Code introduction


This function zips a variable number of iterable arguments together. If some of the iterables are shorter than the others, it fills them with a specified fillvalue until all iterables are of the same length.


Technology Stack : zip_longest

Code Type : Function

Code Difficulty : Intermediate


                
                    
def zip_longest(*args, fillvalue=0):
    zip_longest = zip_longest(*args, fillvalue=fillvalue)
    for item in zip_longest:
        yield item                
              
Tags: