You can download this code by clicking the button below.
This code is now available for download.
Create a generator that merges multiple iterable objects. If the lengths are not consistent, use fillvalue to fill in the missing parts.
Technology Stack : itertools
Code Type : Function
Code Difficulty : Intermediate
def zip_longest(*args, fillvalue=None):
from itertools import zip_longest
def generator():
for iterable in args:
for element in iterable:
yield element
while True:
for fill in fillvalue:
yield fill
return list(generator())