[Tutor] Counting words

Sean 'Shaleh' Perry shalehperry@attbi.com
Fri, 05 Apr 2002 07:59:10 -0800 (PST)


> Like this?
> 
> for word in reg.split(text):
>     if word == "": continue
>     word = string.lower(word)
>     occurences[word] = occurences.get(word,0)+1
> 

the python idiom is 'if not word: continue'.