unified code for 'for' loops and list comprehensions