Oh sorry indentation was messed here...the wordlist = countDict.keys() wordlist.sort() should be outside the word loop.... now def create_words(lines): cnt = 0 spl_set = '[",;<>{}_&?!():-[\.=+*\t\n\r]+' for content in lines: words=content.split() countDict={} wordlist = [] for w in words: w=string.lower(w) if w[-1] in spl_set: w = w[:-1] if w != '': if countDict.has_key(w): countDict[w]=countDict[w]+1 else: countDict[w]=1 wordlist = countDict.keys() wordlist.sort() cnt += 1 if countDict != {}: for word in wordlist: print (word+' '+ str(countDict[word])+'\n')
ok now this is the correct question I am asking... -- http://mail.python.org/mailman/listinfo/python-list