[Tutor] count words

Alan Gauld alan.gauld at freenet.co.uk
Tue Feb 15 19:33:14 CET 2005


> Other than using a several print statments to look for
> seperate words like this, is there a way to do it so
> that I get a individual count of each word:
> 
> word1 xxx
> word2 xxx
> words xxx

The classic approach is to create a dictionary.
Add each word as you come to it and increment the value by one.
At the end the dictionaru contains all unique words with the 
count for each one.

Does that work for you?

Alan G.


More information about the Tutor mailing list