Documents
In the code `data.update({web_isbn: web_isbn})`, is the intention to use the value of the variable `web_isbn` as the key, or should the key be the string "web_isbn"? How does this relate to the later usage of `data.get(f"{web_isbn}", f"{isbn}")`?
In the code `data.update({web_isbn: web_isbn})`, is the intention to use the value of the variable `web_isbn` as the key, or should the key be the string "web_isbn"? How does this relate to the later usage of `data.get(f"{web_isbn}", f"{isbn}")`?
Type
Answer
Status
Published
Created
Jan 8, 2026
Updated
Jan 8, 2026
Created by
Dosu Bot
Updated by
Dosu Bot

The code data.update({web_isbn: web_isbn}) uses the value of the variable web_isbn as the key, not the string "web_isbn". For example, if web_isbn is "9781234567890", then data will have an entry { "9781234567890": "9781234567890" }. Later, data.get(f"{web_isbn}", f"{isbn}") tries to retrieve the value for the key equal to the value of web_isbn (i.e., the actual ISBN parsed from the web). If that key does not exist, it falls back to the value of isbn. This logic ensures that the code prioritizes using the ISBN obtained from the web, and only uses the original isbn if the web-parsed one is unavailable. If you want to use a fixed key, you should write data.update({"web_isbn": web_isbn}), but the current code intentionally uses a dynamic key to distinguish between different sources of ISBN information. Reference