You can download this code by clicking the button below.
This code is now available for download.
This function is similar to the built-in `zip` function, but it keeps the longest input sequence, filling shorter sequences with `fillvalue`.
Technology Stack : itertools
Code Type : Function
Code Difficulty : Intermediate
def zip_longest(*args, fillvalue=()):
"""
Similar to the built-in `zip` function, but will keep the longest input sequence.
"""
from itertools import zip_longest
return zip_longest(*args, fillvalue=fillvalue)