Computer Science

What is a list comprehension ? How is it useful ?

Linear Lists

1 Like

Answer

A list comprehension is a concise description of a list that shorthands the list creating for loop in the form of a single statement. The syntax is:

[expression_creating_list for (set of values to iterate upon) condition]

List comprehensions make code compact, more readable, more efficient and are faster to execute.

Answered By

2 Likes


Related Questions