reading-note

https://eng-ehabsaleh.github.io/reading-note/

View on GitHub

List Comprehensions in Python

Let’s start by creating a list of numbers using Python list comprehensions. We’ll take advantage of Python’s range() method as a way to create a list of digits.

By taking advantage of list comprehensions, it’s possible to work on only part of a list. For instance, if you only wanted the even numbers in a given range, you could find them using a filter.

Hopefully you’ve seen the potential of list comprehensions and how they can be used to write more elegant Python code. Writing compact code is essential for maintaining programs and working with teams.Learning to make use of advanced features like list comprehension will save time and improve productivity.Not only will your colleagues thank you when your Python code is more concise and easier to read, but you’ll thank yourself when you come back to a program you haven’t worked on in months and the code is manageable

also there is plenty of ways to make lists using comprehensions such as functions and loops