Combining Lists with Fillvalue

  • Share this:

Code introduction


This function combines an arbitrary number of parameter lists into tuples. If one of the parameter lists is shorter, it fills the missing parts with the fillvalue.


Technology Stack : Built-in function zip_longest

Code Type : Function

Code Difficulty : Intermediate


                
                    
def zip_longest(*args, fillvalue=None):
    zip_longest = zip_longest(*args, fillvalue=fillvalue)
    for i in zip_longest:
        print(i)