Given the following list:
a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
My goal is to end up with the following:
b = [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
My problem with this is, a
does not have a fixed length ( if it did, I wouldn't need any help ). The length of the list is dynamic. Each loop pass adds a number to each sublist.
For example, a
would look like this after the next loop pass:
a = [[1, 2, 3, 4], [4, 5, 6, 7], [7, 8, 9, 10]]
And b
would look like this now:
b = [[1, 4, 7], [2, 5, 8], [3, 6, 9], [4, 7, 10]]
I need the nth element from each sublist each time.
I tried list comprehension, searched this forum, but found no solution to my problem.