For Loop vs List Comprehension

Why we use a list comprehension?

Photo by Claire Satera on Unsplash
https://thagomizer.com/
list = [expression for member in iterable]
Output:
['red', 'pink', 'blue', 'white']

Some benefits of using list comprehension

https://www.thecoderpedia.com/

SOME EXAMPLES

Output:
[1, 4, 9, 16, 25, 36, 49, 64, 81]
Output:
[1, 4, 7]

Computer Engineering

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store