A key is a hashable identifier that lets a Python dictionary associate a stored value with a lookup name. Unlike sequence indexes, keys can typically be integers or strings, making name-value data natural to retrieve. section 4.0 section 4.23
Effective keys support several common dictionary patterns:
- Represent records such as configuration options, website details, usernames, or preferences. section 4.0
- Provide fast membership checks and value retrieval with the in operator. section 4.4
- Remain unique, while values may have any type, including another dictionary. section 4.23
Menu lookup
Store product names as keys in menu. After stripping the user's input, check `if order in menu`; retrieve the associated price when present, or report that the product is unavailable. section 4.4
Parsed user record
When reading a user record, use `user_info[0]` as the dictionary key. A variable can supply a key when its value contains a string. section 5.7









