## Instead of building a list with a loop: b = [] for x in a: b.append(10 * x) foo(b) ## you can often build it much more concisely ## with a list comprehension: foo([10 * x for x in a]) ##or, if foo accepts an arbitrarily iterable (which it usually will), ## a generator expression: foo(10 * x for x in a)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter