Python List Comprehension Exercises
Let’s check out some exercises that will help understand List Comprehension better.
Create an identical list from the first list using list comprehension.
Create a list from the elements of a range from 1200 to 2000 with steps of 130, using list comprehension.
Use list comprehension to contruct a new list but add 6 to each item.
Using list comprehension, construct a list from the squares of each element in the list.
Using list comprehension, construct a list from the squares of each element in the list, if the square is greater than 50.
Given dictionary is consisted of vehicles and their weights in kilograms. Contruct a list of the names of vehicles with weight below 5000 kilograms. In the same list comprehension make the key names all upper case.