🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Modules and Libraries: all 14 questions

Quiz: Modules and Libraries · Question 2 of 14

What does this print? (code)

What does this print?

from collections import Counter
print(Counter("aabbbc")["b"])
  1. A.2
  2. B.3
  3. C.1
  4. D.b
Answer & explanation

Correct answer: 3

Counter counts each character; "b" appears 3 times.

Can you get the rest right without peeking?

Take the timed Quiz: Modules and Libraries quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →