def anagrams(phrase, shortest=2): return find_anagrams(phrase.replace(' ',''),'', shortest) def find_anagrams(letters, previous_word, shortest): results = set() for w in find_words(letters): if len(w) >= shortest and w > previous_word: remainder = removed(letters, w) if remainder: for rest in find_anagrams(remainder, w, shortest): results.add(w + '' + rest) else: results.add(w) return results