You can use itertools.zip_longest()
(which is part of the standard library, and is an alternative to the builtin zip()
, which truncates its output to the shortest of its arguments), to reorder/rotate the lists, and then use a double list comprehension to flatten that output.
from itertools import zip_longest
inp = [
[4,7,9,10],
[5,14,55,24,121,56, 89,456, 678],
[100, 23, 443, 34, 1243,]
]
output = [
elem
for tup in zip_longest(*inp) # if we don't provide a fillvalue...
for elem in tup # ...missing elements are replaced with None...
if elem is not None # ...which we can filter out
]
# [4, 5, 100, 7, 14, 23, 9, 55, 443, 10, 24, 34, 121, 1243, 56, 89, 456, 678]