List comprehension is an elegant and concise way to create a new list from an existing list in Python.
In this blog post, you will learn how to code python list comprehension.
Step 1: Create a list
my_list = [1, 2, 3, 4, 5]
Step 2: Print the list
print([i for i in my_list])
Output:
[1, 2, 3, 4, 5]