Checking the Number of Elements in Python `Counter`

Python 2.7 / 3.1 introduced awesome collections.Counter.

My question is: how do I calculate how many “elements” a counter has?

I want it:

len(list(counter.elements()))

But in short.

+5
source share
1 answer
sum(counter.itervalues())

+4
source

All Articles