Combining Iterables with Fillvalue

  • Share this:

Code introduction


The function combines iterables together. If the iterables have different lengths, it fills the missing parts with fillvalue.


Technology Stack : itertools

Code Type : Function

Code Difficulty : Intermediate


                
                    
def zip_longest(*args, fillvalue=None):
    zip_longest = itertools.zip_longest(*args, fillvalue=fillvalue)
    for values in zip_longest:
        yield values                
              
Tags: