Splitting a nested list into two lists

list, nested, python, split

Solution

This is what the builtin function `zip` is for.

my_list2, my_list1 = zip(*my_list)

If you want lists instead of tuples, you can do

my_list2, my_list1 = map(list, zip(*my_list))

Problem

I have a nested list like this: ``` my_list = [[1320120000000, 48596281], [1320206400000, 48596281], [1320292800000, 50447908]] ``` I would like to split it into something that looks like this: ``` my_list1 = [48596281, 48596281, 50447908] my_list2 = [1320120000000, 1320206400000, 1320292800000] ``` I know that this is fairly simple, but I haven't been able to get it to work. Any help would be much appreciated.

Original source

Related problems