🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Arrays & Hashing Quiz: all 8 questions

Arrays & Hashing Quiz · Question 4 of 8

What does this code print? (code)

What does this code print?

from collections import Counter
c = Counter("banana")
print(c["a"])
Answer & explanation

Correct answer: 3

"banana" contains three a's. Counter maps each character to its frequency.

Can you get the rest right without peeking?

Take the timed Arrays & Hashing Quiz quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →