[Tutor] Simple counter to determine frequencies of words in a document
ajarncolin at gmail.com
Sun Nov 21 00:50:19 CET 2010
>However, even with countWords2, which is supposed to overcome this
>problem, it feels as if I've entered an infinite loop.
Just my twopenneth, I'm a noob and I'm not going to try such a big file on
my old machine, but:
1. Maybe create a *set* from the wordlist, loop through that, so you call
"count" on wordlist only once. OR
2. Use collections.defaultdict(int) and loop through wordlist and do
dic[word] += 1
if not ErrorMessage:
" noErrorMessage != correctAnswer"
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor