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.
Practice dictionaries & sets with self-contained questions. Check your answer, then use the explanation to understand the reasoning.
counts = {"a": 1}
counts["a"] = 2
print(counts["a"])Answer: 2
Assigning a second value to the same key replaces its previous value.