Skip to content

Instantly share code, notes, and snippets.

@acrymble
Created July 5, 2011 19:24
Show Gist options
  • Save acrymble/1065642 to your computer and use it in GitHub Desktop.
Save acrymble/1065642 to your computer and use it in GitHub Desktop.
Python count items in a list result
String
it was the best of times it was the worst of times it was the age of wisdom it was the age of foolishness
List
['it', 'was', 'the', 'best', 'of', 'times', 'it', 'was',
'the', 'worst', 'of', 'times', 'it', 'was', 'the', 'age',
'of', 'wisdom', 'it', 'was', 'the', 'age', 'of',
'foolishness']
Frequencies
[4, 4, 4, 1, 4, 2, 4, 4, 4, 1, 4, 2, 4, 4, 4, 2, 4, 1, 4,
4, 4, 2, 4, 1]
Pairs
[('it', 4), ('was', 4), ('the', 4), ('best', 1), ('of', 4),
('times', 2), ('it', 4), ('was', 4), ('the', 4),
('worst', 1), ('of', 4), ('times', 2), ('it', 4),
('was', 4), ('the', 4), ('age', 2), ('of', 4),
('wisdom', 1), ('it', 4), ('was', 4), ('the', 4),
('age', 2), ('of', 4), ('foolishness', 1)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment