Combining Iterables with zip_longest

  • Share this:

Code introduction


This function takes any number of iterable objects as arguments and combines them into pairs using `itertools.zip_longest`. If an iterable is shorter than the others, it is filled with a `fillvalue`, which defaults to None.


Technology Stack : itertools

Code Type : Function

Code Difficulty : Intermediate


                
                    
def zipped_pairs(*args):
    from itertools import zip_longest
    return list(zip_longest(*args))                
              
Tags: