Raymond Hettinger added the comment: The introductory example already shows both ways of using a Counter:
1) How to tally one at a time: cnt = Counter() for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']: cnt[word] += 1 2) How to count directly from a list: words = re.findall(r'\w+', open('hamlet.txt').read().lower()) Counter(words).most_common(10) ---------- assignee: docs@python -> rhettinger resolution: -> not a bug status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20068> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com