An optional field
Take your time, follow the code and check your understanding.
The codeDictionaries
user = {"name": "Asha"}
print(user["city"]) # city is optionalYour answer3 min · no timer
Show solution and explanation
Indexing requires the key to exist. user.get("city", "Unknown") handles a missing optional field.
The code raises KeyError; use get with a fallback.