Combining Iterables with Fillvalue Using zip_longest

  • Share this:

Code introduction


The function is used to combine multiple iterable objects together. If some iterators have been exhausted, it uses fillvalue to fill.


Technology Stack : itertools

Code Type : Function

Code Difficulty : Intermediate


                
                    
def zip_longest(*iterables, fillvalue=None):
    from itertools import zip_longest as zip_longest_imp

    return zip_longest_imp(*iterables, fillvalue=fillvalue)                
              
Tags: