Zip Longest Iterator with FillValue

  • Share this:

Code introduction


Create an iterator that returns tuples, filling with a specified value if the iterators are exhausted.


Technology Stack : Create an iterator that returns tuples, filling with a specified value if the iterators are exhausted. It uses the `itertools` module.

Code Type : Function

Code Difficulty : Intermediate


                
                    
def zip_longest(*args, fillvalue=()):
    from itertools import zip_longest as _zip_longest
    return _zip_longest(*args, fillvalue=fillvalue)