differ) [[ ][ ]for in range(len( ))for in range(len( [ ])) [ ][ + update in place [[ ][ ]we can' really do the same with list comprehensionsas they make new listsbut we could always assign their results to the original name for similar effect for examplewe can apply an operation to every item in matrixproducing results in either simple vector or matrix of the same shape[col for row in for col in row[ assign to to retain new value [[col for col in rowfor row in [[ ][ ][ ]to understand thesetranslate to their simple statement form equivalents that follow --indent parts that are further to the right in the expression (as in the first loop in the following)and make new list when comprehensions are nested on the left (like the second loop in the followingas its statement equivalent makes clearerthe second expression in the preceding works because the row iteration is an outer loopfor each rowit runs the nested column iteration to build up one row of the result matrixres [for row in mfor col in rowres append(col statement equivalents indent parts further right res [ res [for row in mtmp [for col in rowtmp append(col res append(tmpleft-nesting starts new list res [[ ][ ][ ]finallywith bit of creativitywe can also use list comprehensions to combine values of multiple matrixes the following first builds flat list that contains the result of multiplying the matrixes pairwiseand then builds nested list structure having the same values by nesting list comprehensions againm [[ ][ ][ ]list comprehensions and functional tools