Aggregating Iterables into Tuples with FillValue

  • Share this:

Code introduction


This function takes any number of iterables and aggregates them into tuples. If the iterables are of unequal length, missing values are filled with `fillvalue`.


Technology Stack : itertools

Code Type : Function

Code Difficulty : Intermediate


                
                    
def zip_longest(*args, fillvalue=None):
    """
    This function takes any number of iterables and aggregates them into tuples.
    If the iterables are of unequal length, missing values are filled with `fillvalue`.
    """
    from itertools import zip_longest

    return zip_longest(*args, fillvalue=fillvalue)                
              
Tags: