PRACTICE / UNDERSTAND / REPEAT

Python: Dictionaries & sets

Practice dictionaries & sets with self-contained questions. Check your answer, then use the explanation to understand the reasoning.

30 questionsAnswers explainedFree · no login
Question 1 of 30
Dictionaries & sets · MCQQuestion link ↗

What does the dictionary lookup print?

counts = {"a": 1}
counts["a"] = 2
print(counts["a"])
Choose one answer
Answer & explanation

Answer: 2

Assigning a second value to the same key replaces its previous value.