Skip to content
Advertisement

python 3d list manipulation

I have a 3d list aa = [[[2, 3, 4, 5], [ 6, 7, 8, 9]], [[11, 12, 14, 15]]], which consists of two 2d lists how do I get this result [[2, 6], [11]] the first element of each sub list.

JavaScript

gives [2,6,11]

Advertisement

Answer

You can do it with a list comprehension:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement