I am calling:
c = Counter()

...exactly as in the collections example code here:

http://docs.python.org/py3k/library/collections.html?highlight=collections#collections.Counter

but it gives me this error:
NameError: name 'Counter' is not defined

Anyone know why? Note that I have 3.1.2 and yes I include "import collections".

Thanks

I assume you mean this example ...

# tally occurrences of words in a list
# needs Python3

import collections

cnt = collections.Counter()
for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:
    cnt[word] += 1

print(cnt)

"""my result -->
Counter({'blue': 3, 'red': 2, 'green': 1})
"""
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.