Javatpoint Logo
Javatpoint Logo

Python List Comprehension

List Comprehension is defined as an elegant way to define, create a list in Python and consists of brackets that contains an expression followed by for clause. It is efficient in both computationally and in terms of coding space and time.

Signature

The list comprehension starts with '[' and ']'.

[ expression for item in list if conditional ]

Example

Output:

['P', 'y', 't', 'h', 'o', 'n']

Example

Output:

['P', 'y', 't', 'h', 'o', 'n']

Example

Output:

OS
Next TopicPython Tutorial




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA