You can try the following:
In [30]: from itertools import izip_longest In [31]: l = ['a', 'b'] In [32]: l2 = [1, 2, 3, 4] In [33]: [item for slist in izip_longest(l, l2) for item in slist if item is not None] Out[33]: ['a', 1, 'b', 2, 3, 4]
izip_longest "zips" combines the two lists, but instead of stopping in the shortest list, it continues until the longest is exhausted:
In [36]: list(izip_longest(l, l2)) Out[36]: [('a', 1), ('b', 2), (None, 3), (None, 4)]
Then you add items by iterating over each item in each pair in the encrypted list, omitting those that are None . As pointed out by @Blckknight, this will not work properly if the source lists already have None values. If possible in your situation, you can use the fillvalue izip_longest property to fill with something other than None (as @Blckknight does in his answer).
Here is the above example as a function:
In [37]: def interleave(*iterables): ....: return [item for slist in izip_longest(*iterables) for item in slist if item is not None] ....: In [38]: interleave(l, l2) Out[38]: ['a', 1, 'b', 2, 3, 4] In [39]: interleave(l, l2, [44, 56, 77]) Out[39]: ['a', 1, 44, 'b', 2, 56, 3, 77, 4]