Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python Sorted Word frequency count

>>> # Tally occurrences of words in a list
>>> from collections import Counter
>>> cnt = Counter()
>>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:
...     cnt[word] += 1
>>> cnt
Counter({'blue': 3, 'red': 2, 'green': 1})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #Sorted #Word #frequency #count
ADD COMMENT
Topic
Name
3+7 =