Transform iterable data by converting its items or reshaping them into another container. In Python, map applies a function to each item and returns a map iterator; constructors such as list and dict turn iterables into useful data structures. section 5.1.3 section 7.2.2
Choose a pattern to match the transformation:
- Use map(float, numbers_str) to convert each numeric string; wrap it in list(...) when a list is needed. For list output, a list comprehension is presented as the more Pythonic alternative. section 5.1.3 section 7.2.2
- Use zip to pair corresponding items from two iterables, then dict to build key-value entries. The order of the iterables determines the order of each pair. section 5.1.3
numbers_str = ["1.23", "4.56", "7.89"] numbers_float = list(map(float, numbers_str)) assert numbers_float == [1.23, 4.56, 7.89]
The conversion produces [1.23, 4.56, 7.89] from strings using map and list. section 5.1.3
zipped_tasks = dict(zip(id_numbers, titles))
assert zipped_tasks == {101: "Laundry", 102: "Homework", 103: "Soccer"}
The example pairs task IDs with titles to create a dictionary. section 5.1.3



















