Variable-Length Sequence Combination with Fill Value

  • Share this:

Code introduction


Combines variable length sequences into one sequence, filling the shorter sequences with a specified fill value if they are not equal in length.


Technology Stack : itertools

Code Type : Function

Code Difficulty : Intermediate


                
                    
def zip_longest(*args, fillvalue=0):
    from itertools import zip_longest

    return list(zip_longest(*args, fillvalue=fillvalue))                
              
Tags: