13
06 '15
List comprehensions are an easy way to make a list out of another list. For example: list1 = [1, 2, 3, 4, 5, 6] print(list1) list2 = [x**2 for x in list1] print(list2) [1, 2, 3, 4, 5, 6][1, 4, 9, 16, 25, 36] A similar construct exists for dictionaries and is…