Python List Comprehension Exercises
Let’s check out some exercises that will help understand List Comprehension better.
Exercise 16-a
Create an identical list from the first list using list comprehension.
Exercise 16-b
Create a list from the elements of a range from 1200 to 2000 with steps of 130, using list comprehension.
Exercise 16-c
Use list comprehension to contruct a new list but add 6 to each item.
Exercise 16-d
Using list comprehension, construct a list from the squares of each element in the list.
Exercise 16-e
Using list comprehension, construct a list from the squares of each element in the list, if the square is greater than 50.
Exercise 16-f
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.