[docs] [issue20068] collections.Counter documentation leaves out interesting usecase
Raymond Hettinger
report at bugs.python.org
Thu Jun 19 22:05:28 CEST 2014
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 at python -> rhettinger
resolution: -> not a bug
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20068>
_______________________________________
More information about the docs
mailing list