List Comprehension

List comprehensions provide a concise way to create lists.

Snippet:

squares = [x**2 for x in range(10)]\nprint(squares)

Example:

evens = [x for x in range(10) if x % 2 == 0]\nprint(evens)