Computer Science
What is a list comprehension ? How is it useful ?
Linear Lists
2 Likes
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
1 Like
Related Questions
What is a linear list data structure ? Name some operations that you can perform on linear lists.
Suggested situations where you can use these data structures:
(i) linear lists
(ii) stacks
(iii) queues
Enlist some advantages of list comprehensions.
In which situations should you use list comprehensions and in which situations you should not use list comprehensions ?