[Tutor] count words

Ron Nixon nixonron at yahoo.com
Tue Feb 15 17:21:44 CET 2005


I know that you can do this to get a count of home
many times a word appears in a file


f = open('text.txt').read()
print f.count('word')

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

etc.




		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250


More information about the Tutor mailing list