zip_longest Function Overview

  • Share this:

Code introduction


The function is similar to zip(), but it combines multiple iterable objects and extends the shortest one with a specified fill value if necessary.


Technology Stack : itertools

Code Type : Function

Code Difficulty : Intermediate


                
                    
def zip_longest(*iterables, fillvalue=None):
    """Like zip(), but the shortest iterable is extended by fillvalue."""
    from itertools import zip_longest
    return zip_longest(*iterables, fillvalue=fillvalue)                
              
Tags: