An Interest In:
Web News this Week
- April 22, 2024
- April 21, 2024
- April 20, 2024
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
July 13, 2021 05:13 pm GMT
Original Link: https://dev.to/saifullah/python-list-comprehension-2o06
Python list comprehension
Ever use list comprehension in Python?
If not here is very beautiful use of list comprehension in Python which will make your code more neat and readable.
First of all what is list comprehension?
List comprehension is a syntax, list comprehension offer a shorter syntax when you want to create a new list based on the values of an existing list.
Here is the SYNTAX for it
[expression for item in iterable if condition == True]
Below I have shown two examples
One without using list comprehension and another with list comprehension.
Original Link: https://dev.to/saifullah/python-list-comprehension-2o06
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To