Explain python code in attachment

can you explain step by step execution for the code in attached.

Hi @pratik2306,
Here we have a 3D array

step by step we have :

1 - [k for k in range(3)] => [0,1,2]
2 - [[k for k in range(3)] for j in range(3)] => [[0,1,2] for j in range(3)] = > [[0, 1, 2], [0, 1, 2], [0, 1, 2]]
3 - [[k for k in range(3)] for j in range(3)] for i in range(3)] => [[0, 1, 2], [0, 1, 2], [0, 1, 2]] for i in range(3) => [[[0, 1, 2], [0, 1, 2], [0, 1, 2]], [[0, 1, 2], [0, 1, 2], [0, 1, 2]], [[0, 1, 2], [0, 1, 2], [0, 1, 2]]]

That mean

matrix = [
                   [
                        [0, 1, 2], 
                        [0, 1, 2],
                        [0, 1, 2]
                  ], 
                  [    
                        [0, 1, 2], 
                        [0, 1, 2],
                        **[0, 1, 2]**
                  ],
                  [
                        [0, 1, 2], 
                        [0, 1, 2],
                        [0, 1, 2]
                  ]
              ]

Now for matrix[1][2] you’ve just to get the 2nd item on level 1 and the 3 item on level 2

Regard