Combining Iterables with Fillvalue

  • Share this:

Code introduction


The function is used to combine multiple iterable objects together. If one iterator runs out, the fillvalue is used to fill in the remaining iterators.


Technology Stack : Built-in library

Code Type : Function

Code Difficulty : Intermediate


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