In some programming languages (especially Python), list comprehension is a method of manipulating lists in a compact/concise way. Comprehensions use the same keywords as loop and conditional blocks, and aim to focus on the actual data rather than on the procedure — which gives us different ways of thinking about our logic.
The general syntax of list comprehension is:
Other data types, like sets or dictionaries, also have corresponding comprehensions. That said, past a simple level they stop being useful clarifying tools and we should then just use functions.
Example
To iterate through a list and find even numbers:
With list comprehension: