1. Home
  2. Data Science
  3. Python
  4. What is the output of the following Python code snippet?

Added 25 Nov 2026

What is the output of the following Python code snippet?

from collections import Counter
print(Counter('aaabbc'))
  1. Counter({'a': 3, 'b': 2, 'c': 1}) Correct answer
  2. {'a': 3, 'b': 2, 'c': 1} sorted
  3. ['a', 'b', 'c']
  4. 6

Correct answer

A. Counter({'a': 3, 'b': 2, 'c': 1})

5 views

MCQSEXAM

Explanation

Counter counts hashable items and orders output by frequency.

Reference

Asked in: Python Interview Dictionaries

https://docs.python.org/3/tutorial/datastructures.html#dictionaries

Preparing for an exam?

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs