Merging Iterables with Fillvalue

  • Share this:

Code introduction


This function merges multiple iterable objects into an iterator. If the iterable objects are of different lengths, it fills the shorter ones with the fillvalue.


Technology Stack : itertools

Code Type : Function

Code Difficulty : Intermediate


                
                    
def zip_longest(*args, fillvalue=None):
    from itertools import zip_longest
    return list(zip_longest(*args, fillvalue=fillvalue))
                        
              
Tags: