🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: The collections Module: all 10 questions

Quiz: The collections Module · Question 2 of 10

What does Counter(["x"])["y"] return?

What does Counter(["x"])["y"] return?

  1. A.None
  2. B.KeyError
  3. C.0
  4. D.1
Answer & explanation

Correct answer: 0

A Counter returns 0 for missing items instead of raising KeyError.

Can you get the rest right without peeking?

Take the timed Quiz: The collections Module quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →