Step: Dictionaries: access and get()
Dictionaries: access and get()
dict["key"] raises KeyError if the key is missing; dict.get("key", default) returns default instead.
Why it matters: .get() is the safe way to read an optional key without wrapping every access in a try/except.
Example: for {"a": 1}, d.get("b", 0) is 0, but d["b"] raises.
Your turn: print user's name (bracket access) and a fallback for the missing email key (.get with a default).
Pitfall: .get("email") with no default returns None, not an error — easy to forget and get a silent None in your output.
Setup:
Your code:Expected output:
Step 7 of 18