• Register
110 points
7
List Comprehension in python

Today we will see in our website kodlogs what is list comprehension in Python. It is a compact code which is of single line. If you are learning any programming language then you will understand quickly. From other language.  Python is much easier. Most programmers use list comprehension to create programs. Not to worry too much. List comprehension is not something like that. It is a task that allows you to create a new list. To perform a task.  Then a list will be created .

1.List Comprehension

2.Set Comprehension

3.Dictionary Comprehension

 If you use list comprehension, a new list will be created. If you want set comprehension, a set will be invented. If you want dictionary comprehension, a dictionary will give comprehension.  In this we have to use conditioning. We know how to use for loop so it is very easy for us. The work we do with for loop will do the same work in a line list compilation.  No need to write, so why write so much code when more hours of work is done in minutes. List Comprehension should be used.  The three line code in the for loop is the work we will write in one line. It is called list comprehension. Let's look at it in detail, put it into practice and try to understand these functions more.  There is a lot to learn in side kodlogs.

Syntax:-

New-list=[expression for item in itterable-object if-statement.
110 points
7