Editor

Count Character Frequency

Beginner · Write the code · from Python collections: Counter, defaultdict, deque, and More

From the lesson: Python collections: Counter, defaultdict, deque, and More

Imagine you have a basic toolbox with a hammer and a screwdriver. They work fine for simple jobs. But when you're building a deck, you really want a power drill, a level, and a tape measure.

Read the lesson

Use Counter from the collections module to count how many times each character appears in the string 'abracadabra'. Print the Counter object.

# Import Counter and count characters in 'abracadabra'

More collections exercises

All Python exercises · 50 practice problems · Standard Library Essentials quiz