Problem loading a file of words

Robert Kern rkern at ucsd.edu
Mon Jul 25 06:19:34 CEST 2005


Devan L wrote:

> Heh, it reminds me of the code I used to write.
> 
> def sort_string(word):
>     return ''.join(sorted(list(word.lower())))
> f = open('dictionary.txt','r')
> lines = [line.rstrip('\n') for line in f.readlines()]
> f.close()
> dictionary = dict((sort_string(line),line) for line in lines)

That's definitely not the kind of dictionary that he wants.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter




More information about the Python-list mailing list