the brackets you code an expression that names variable followed by what looks like for loop header that names the same variable python then collects the expression' results for each iteration of the implied loop the effect of the preceding example is similar to that of the manual for loop and the map call list comprehensions become more convenientthoughwhen we wish to apply an arbitrary expression to an iterable instead of function[ * for in range( )[ herewe've collected the squares of the numbers through (we're just letting the interactive prompt print the resulting list objectassign it to variable if you need to retain itto do similar work with map callwe would probably need to invent little function to implement the square operation because we won' need this function elsewherewe' typically (but not necessarilycode it inlinewith lambdainstead of using def statement elsewherelist(map((lambda xx * )range( ))[ this does the same joband it' only few keystrokes longer than the equivalent list comprehension it' also only marginally more complex (at leastonce you understand the lambdafor more advanced kinds of expressionsthoughlist comprehensions will often require considerably less typing the next section shows why adding tests and nested loopsfilter list comprehensions are even more general than shown so far for instanceas we learned in you can code an if clause after the for to add selection logic list comprehensions with if clauses can be thought of as analogous to the filter builtin discussed in the preceding -they skip an iterable' items for which the if clause is not true to demonstratefollowing are both schemes picking up even numbers from to like the map list comprehension alternative of the prior sectionthe filter version here must invent little lambda function for the test expression for comparisonthe equivalent for loop is shown here as well[ for in range( if = [ list(filter((lambda xx = )range( ))[ res [for in range( )if = res append(xlist comprehensions and functional tools