less general tooland often requires extra helper functions or lambdas moreoverwrapping comprehension in parentheses instead of square brackets creates an object that generates values on request to save memory and increase responsivenessmuch like map in -- topic we'll take up in the next selecting items in iterablesfilter the map function is primary and relatively straightforward representative of python' functional programming toolset its close relativesfilter and reduceselect an iterable' items based on test function and apply functions to item pairsrespectively because it also returns an iterablefilter (like rangerequires list call to display all its results in for examplethe following filter call picks out items in sequence that are greater than zerolist(range(- )[- - - - - an iterable in list(filter((lambda xx )range(- ))[ an iterable in we met filter briefly earlier in sidebarand while exploring iterables in items in the sequence or iterable for which the function returns true result are added to the result list like mapthis function is roughly equivalent to for loopbut it is built-inconciseand often fastres [for in range(- )if res append(xthe statement equivalent res [ also like mapfilter can be emulated by list comprehension syntax with often-simpler results (especially when it can avoid creating new function)and with similar generator expression when delayed production of results is desired--though we'll save the rest of this story for the next [ for in range(- if [ use (to generate items combining items in iterablesreduce the functional reduce callwhich is simple built-in function in but lives in the functools module in xis more complex it accepts an iterable to processbut it' not an iterable itself--it returns single result here are two reduce calls that compute the sum and product of the items in list advanced function topics