On May 9, 1:45 am, [EMAIL PROTECTED] wrote: > >>> key = ''.join(sorted(word)) > > I tend to strip and lower the word as well, otherwise "Hello" and > "hello" do not compare...depends on what you want though! > Plus you might get a lot of "word\n" as keys... > > My technique is the this way > > def anagram_finder(words): > anagrams = {} > for word in words: > word = word.strip() > key = ''.join(sorted(word.lower())) > anagrams.setdefault(key, []).append(word) > return anagrams
What would be the best method to print the top results, the one's that had the highest amount of anagrams?? Create a new histogram dict? -- http://mail.python.org/mailman/listinfo/python-list