Combining Iterables with Fillvalue

  • Share this:

Code introduction


The function combines multiple iterable objects into an iterator. If the iterables have different lengths, it fills the shorter ones with fillvalue.


Technology Stack : Built-in function zip_longest

Code Type : Function

Code Difficulty : Intermediate


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