I am calling:
c = Counter()

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


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".


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


"""my result -->
Counter({'blue': 3, 'red': 2, 'green': 1})