PRACTICE / UNDERSTAND / REPEAT
Python practice question
Practice dictionaries & sets with self-contained questions. Check your answer, then use the explanation to understand the reasoning.
1 questionAnswers explainedFree · no login
Try this question
What does the dictionary lookup print?
counts = {"a": 1}
counts["a"] = 2
print(counts["a"])
Answer & explanation
Answer: 2
Assigning a second value to the same key replaces its previous value.