A dictionary stores key-value pairs so a key can retrieve its mapped value. It offers a clear alternative to long, repetitive if-else chains. section 3.2.3
Mapping day indexes to names
Instead of testing seven conditions, define one lookup dictionary: days_of_week = {1: "Sunday", 2: "Monday", 3: "Tuesday", 4: "Wednesday", 5: "Thursday", 6: "Friday", 7: "Saturday"}. Retrieve a name with day = days_of_week[day_index]. This reduces the mapping to two clear lines and reduces opportunities for typos. section 3.2.3
Dictionaries also organize data in practical workflows. Stock-price downloads can use ticker symbols as keys and their returned data frames as values, while a separate failures collection records invalid tickers when exception handling allows processing to continue. section 3.6.3
















































