I have arbitrary lists, for instance here are three lists:
a = [1,1,1,1]
b = [2,2,2,2]
c = [3,3,3,3]
And I want transpose them together in order to get the output like this:
f_out = [1,2,3]
g_out = [1,2,3]
...
n_out = [1,2,3]
As, you can see, I just converted "columns" to "rows".
The issue is a solution has to be independent of the lists length.
For example:
a = [1,1]
b = [2]
c = [3,3,3]
# output
f_out = [1,2,3]
g_out = [1,3]
n_out = [3]
itertools.zip_longest
-- That's almost what you want, you'd just have to filter out the extra padding. – Zestf
,g
, andh
result from lininga
,b
, andc
up horizontally and reading top to bottom. – Sauncho