dict.fromkeys()
dict.fromkeys() works on a dictionary — labelled data like marks["Asha"] = 90. Keys map to values. Loop with .items() when you need both.
dict.fromkeys() — output — {'Asha': 0, 'Ravi': 0}.
Trap for dict.fromkeys() — writing d[missing] in a viva. Prefer get when the key might not exist.
{ "Asha": 90, "Ravi": 85 }
│ │
key valueExam tip
get vs [] — one sentence + tiny dict of marks.