[ add to each item in column [row[ for row in if row[ = filter out odd items [ the first operation herefor instanceadds to each item as it is collectedand the second uses an if clause to filter odd numbers out of the result using the modulus expression (remainder of divisionlist comprehensions make new lists of resultsbut they can be used to iterate over any iterable object-- term we'll flesh out later in this preview herefor instancewe use list comprehensions to step over hardcoded list of coordinates and stringdiag [ [ ][ifor in [ ]diag [ collect diagonal from matrix doubles [ for in 'spam'doubles ['ss''pp''aa''mm'repeat characters in string these expressions can also be used to collect multiple valuesas long as we wrap those values in nested collection the following illustrates using range-- built-in that generates successive integersand requires surrounding list to display all its values in only ( makes physical list all at once)list(range( )[ list(range(- )[- - - (list(required in - to + by (need list(in [[ * * for in range( )multiple values"iffilters [[ ][ ][ ][ ][[xx for in range(- if [[ ][ ][ ]as you can probably telllist comprehensionsand relatives like the map and filter built-in functionsare too involved to cover more formally in this preview the main point of this brief introduction is to illustrate that python includes both simple and advanced tools in its arsenal list comprehensions are an optional featurebut they tend to be very useful in practice and often provide substantial processing speed advantage they also work on any type that is sequence in pythonas well as some types that are not you'll hear much more about them later in this book as previewthoughyou'll find that in recent pythonscomprehension syntax has been generalized for other rolesit' not just for making lists today for exampleenclosing comprehension in parentheses can also be used to create generators that produce results on demand to illustratethe sum built-in sums items in sequence--in this examplesumming all items in our matrix' rows on requestg (sum(rowfor row in mnext( introducing python object types create generator of row sums iter(gnot required here