Creating a zip_longest Function

  • Share this:

Code introduction


The function takes any number of iterable arguments and returns an iterator that combines the input iterables together. If some iterables are shorter than others, it uses `fillvalue` to fill in the missing values.


Technology Stack : itertools

Code Type : Function

Code Difficulty : Intermediate


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

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