Exercise 1: An Unrecognized Color Name Falls Back Correctly — Possible Solution ==================================================================== THE TEST ------------------------------ parse_color('cornflowerblue') RESULT ------------------------------ (0, 0, 0) -- black, DEFAULT_COLOR's own value 'cornflowerblue' is a genuine, real CSS3 named color -- it isn't a typo or an invalid string -- but it simply isn't one of the handful of entries this chapter's own simplified NAMED_COLORS table defines. WHY THE FALLBACK WORKS ------------------------------ parse_color's own entire body is: def parse_color(name): return NAMED_COLORS.get(name, DEFAULT_COLOR) dict.get(key, default) returns NAMED_COLORS[name] if that exact key exists, and the supplied DEFAULT_COLOR otherwise -- it never raises KeyError. Since 'cornflowerblue' isn't a key in NAMED_COLORS, the lookup falls through to DEFAULT_COLOR, (0, 0, 0). WHY A HAND-BUILT TABLE CAN NEVER COVER EVERY CSS COLOR NAME ------------------------------ The CSS Color Module defines 140+ named colors -- everything from common ones like 'red' and 'blue' to genuinely obscure ones like 'papayawhip', 'mediumspringgreen', and 'rebeccapurple'. This course's own NAMED_COLORS table only lists the handful of colors actually used across this course's own examples and exercises (red, blue, green, navy, purple, yellow, white, black, orange) -- a deliberate, honest simplification, not an attempt to be exhaustive. Enumerating all 140+ by hand would be real, tedious work that adds nothing pedagogically to what this chapter is actually teaching (bounds-checked rasterizing), so the table stays small and the fallback handles everything it doesn't cover. WHY THIS WORKS AS AN ANSWER ------------------------------ This mirrors Chapter 6's own DEFAULT_CHAR_WIDTH_EM fallback for an unlisted character, and real browsers themselves: an actual browser handed a genuinely invalid or unsupported color value doesn't crash the whole render -- it substitutes a defined fallback (in real CSS, this is formally the property's own initial value) and keeps going. Falling back to black specifically is a reasonable, visible default -- it's clearly distinguishable on a typical white canvas background, making an unrecognized color's own presence obvious rather than silently invisible (which a fallback to white, for instance, would risk being on this chapter's own default white canvas).