Ron,

<snip>is there a way to do it so
> that I get a individual count of each word:
> 
> word1 xxx
> word2 xxx
> words xxx
> 
> etc.

Ron, I'm gonna throw some untested code at you. Let me know if you
understand it or not:

word_counts = {}
for line in f:
    for word in line.split():
        if word in word_counts:
            word_counts[word] += 1
        else:
            word_counts[word] = 1

for word in word_counts:
    print "%s %d" % (word, word_counts[word])

Peace
Bill Mill
bill.mill at gmail.com
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to