You can download this code by clicking the button below.
This code is now available for download.
This function combines multiple iterable objects together. If they are of unequal length, it fills in the missing parts with fillvalue.
Technology Stack : itertools, zip_longest
Code Type : Function
Code Difficulty : Intermediate
def zip_longest(*iterables, fillvalue=None):
"""
Zip equal length sequences together, but allow each sequence to be of different lengths.
If the sequences are of unequal length, missing values are filled-in with fillvalue.
Default fillvalue is None.
"""
from itertools import zip_longest
import itertools
return list(zip_longest(*iterables, fillvalue=fillvalue))