Skip to content

Home / Glossary / List Comprehension

Python

List Comprehension

By Sitraka Forler · Lecturer, Durham Business SchoolUpdated 13 September 2026 About this site

Compact syntax to build a list from an iterable.

List comprehensions replace verbose for-loops with a one-line expression. They are idiomatic Python and often faster than equivalent loops.

Example

returns = [p/prices[i-1]-1 for i, p in enumerate(prices[1:], 1)]

Practise List Comprehension hands-on - free, in your browser

Related terms