[[ ][ ][ ][ [row][coln[row][colfor row in range( for col in range( )[ [[ [row][coln[row][colfor col in range( )for row in range( )[[ ][ ][ ]this last expression works because the row iteration is an outer loop againit' equivalent to this statement-based coderes [for row in range( )tmp [for col in range( )tmp append( [row][coln[row][col]res append(tmpand for more funwe can use zip to pair items to be multiplied--the following comprehension and loop statement forms both produce the same list-of-lists pairwise multiplication result as the last preceding example (and because zip is generator of values in xthis isn' as inefficient as it may seem)[[col col for (col col in zip(row row )for (row row in zip(mn)res [for (row row in zip(mn)tmp [for (col col in zip(row row )tmp append(col col res append(tmpcompared to their statement equivalentsthe list comprehension versions here require only one line of codemight run substantially faster for large matrixesand just might make your head explodewhich brings us to the next section don' abuse list comprehensionskiss with such generalitylist comprehensions can quickly becomewellincomprehensibleespecially when nested some programming tasks are inherently complexand we can' sugarcoat them to make them any simpler than they are (see the upcoming permutations for prime exampletools like comprehensions are powerful solutions when used wiselyand there' nothing inherently wrong with using them in your scripts at the same timecode like that of the prior section may push the complexity envelope more than it should--andfranklytends to disproportionately pique the interest of those holding the darker and misguided assumption that code obfuscation somehow implies talent because such tools tend to appeal to some people more than they probably shouldi need to be clear about their scope here comprehensions and generations