nestedso won' even try showing it here 'll leave its coding as an exercise for zen mastersex-lisp programmersand the criminally insaneexamplelist comprehensions and matrixes not all list comprehensions are so artificialof course let' look at one more application to stretch few synapses as we saw in and one basic way to code matrixes ( multidimensional arraysin python is with nested list structures the followingfor exampledefines two matrixes as lists of nested listsm [[ ][ ][ ] [[ ][ ][ ]given this structurewe can always index rowsand columns within rowsusing normal index operationsm[ [ row [ ][ row item list comprehensions are powerful tools for processing such structuresthoughbecause they automatically scan rows and columns for us for instancealthough this structure stores the matrix by rowsto collect the second column we can simply iterate across the rows and pull out the desired columnor iterate through positions in the rows and index as we go[row[ for row in [ column [ [row][ for row in ( )[ using offsets given positionswe can also easily perform tasks such as pulling out diagonal the first of the following expressions uses range to generate the list of offsets and then indexes with the row and column the samepicking out [ ][ ]then [ ][ ]and so on the second scales the column index to fetch [ ][ ] [ ][ ]etc (we assume the matrix has the same number of rows and columns)[ [ ][ifor in range(len( ))[ [ [ ][len( )- -ifor in range(len( ))[ comprehensions and generations diagonals