What is LIST comprehensions features of Python used for?- LIST comprehensions features were introduced in Python version 2.0, it creates a new list based on existing list.
- It maps a list into another list by applying a function to each of the elements of the existing list.
- List comprehensions creates lists without using map() , filter() or lambda form.
- It provides a concise way to create lists.
- They consist of a bracket that contains an expression which will be followed by a clause and then add zero or more clauses.
- The output will be a new list that will result from evaluating the expression in the context for and the clauses that follow it.
- It always returns a result list.
|