Python#s zip_longest Function: Aggregating Iterables with Fillvalue

  • Share this:

Code introduction


Create an iterator that aggregates elements from each of the iterables in the given iterable. If the iterables are of uneven length, missing values are filled-in with fillvalue.


Technology Stack : itertools

Code Type : Function

Code Difficulty : Intermediate


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

    return zl(args, fillvalue=fillvalue)                
              
Tags: