A dictionary key is a hashable object that identifies a value in a mapping. Keys are unique, so assigning a second value to one replaces the first. section 4.1.3
Use keys to build and work with Python dictionaries:
- Create entries with square brackets: answers['name'] = 'Sir Lancelot'. section 4.1.1
- Retrieve a value with its key, or use get() when a missing key should return None or a supplied default instead of raising KeyError. section 4.1.2
- Check membership with 'key' in dictionary, and inspect keys, values, or pairs with keys(), values(), and items(). section 4.1.2 section 4.1.3
- Use strings, integers, or floats as keys; lists cannot serve because keys must be immutable. section 4.1.3
Indexing lines by their first letter
Build lookup = {} while reading a file, then store each line with lookup[line[0].upper()] = line.rstrip(). A later letter argument retrieves the matching line; an unknown value produces a helpful message. section 7.1 section 7.3.2
Inspect a complete key assignment in the REPL before extending the dictionary with additional question-and-answer pairs. section 4.1.1










