A great many loops in real programs do one job: take some values, perhaps filter them, change each one, and collect the results. Python has a compact form for that job, called a comprehension, and it is one of the most recognisable features of the language. This lesson shows the three kinds, how conditions and nesting work, and the honest limits of the style.
More lessons in Complete Python Programming