I have a list of lists such that the length of each inner list is either 1 or n (assume n > 1).

>>> uneven = [[1], [47, 17, 2, 3], [3], [12, 5, 75, 33]]

I want to transpose the list, but instead of truncating the longer list (as with zip) or filling the shorter lists with None, I want to fill the shorter lists with their own singular value. In other words, I'd like to get:

This was very helpful because the n=1 inner lists were manufactured. Now I've refactored so the list is [repeat(1), [47, 17, 2, 3], repeat(3), [12, 5, 75, 33]] and I can just do zip(*uneven).
–
kojiroMay 16 '12 at 17:50