I have following list of list:
lst = [[1,3], [3,4], [2,7], [6,5]]
How do I create "oneliner" to get list of max() of each "column"?
so for the example above the resulting list should be following: [6,7], where 6 is the maximum of "column 0" and 7 is the maximum of "column 1".
>Solution :
You can use zip which splits the pairs into two separate tuples:
>>> lst = [[1,3], [3,4], [2,7], [6,5]]
>>> list(zip(*lst))
[(1, 3, 2, 6), (3, 4, 7, 5)]
So, overall:
>>> [max(v) for v in zip(*lst)]
[6, 7]