1

I want to find all common words in the same key of 2 dictionaries. The Key has a list of words as a value, and the key is the length of the items in the value list.

from collections import defaultdict
from itertools import permutations

def unscramble(scrambled_word):
    length=len(scrambled_word)
    unscrambled_word=[]
    unscramble_dict=defaultdict(list)
    
    for r in range(2,length+1):
        permutation_object=permutations(scrambled_word, r)
        unscrambled_list=[''.join(permutation) for permutation in permutation_object]
        unscramble_dict[r].append(unscrambled_list)
    return unscramble_dict


def english_words(scrambled_word):
    length=len(scrambled_word)
    words_list=[]
    words_dict=defaultdict(list)
    with open("english_words.txt") as file_object:
        for line in file_object:
            word=line.strip()
            for r in range(2,length+1):
                if len(word)==r:
                    words_dict[len(word)].append(word)
    return words_dict



def possible_words():
    for i in range(2, length+1):
        if 


print(unscramble("sodwind"))
print(english_words("sodwind"))

0 Answers0