How to verify if indexes of letter from word matches index of letter from words from list in python?
Question: I have multiple functions which return a list of words (each function contains
words that start with the same letter):

    
    
    def get_a():
        #  ..some code
        return words_a  # words_a contain a list with some words that begin with a 
    
    ... # and so on
    
    def get_y():
        #  ..some code
        return words_y  # words_y contain a list with some words that begin with y 
    

Output example: `['yahoo', 'yep', 'yellow']`

Now, I have a random word ( I know its `len` and only some letters which are
located at specific indexes - I also know these )

Supposing that I have the following `partial_word` (I have `0` instead of the
empty spaces):

`partial_word = 00LL0W`

What is the best way of getting a list with words(from all my functions) that
will satisfy the following condition:

  * all known index letters(in my example `L(position2) L(position3) W(position5`) from the `partial_word` will match at the exact same positions the letters from the words from my functions ?
  * another important detail is that each function returns a list with 3-4k words.


Answer: You may make use of the build-in regular expression library

    
    
    import re
    
    partial_word = '00LL0W'
    pattern = '^' + partial_word + '$'
    pattern = pattern.replace('0', '\w')
    
    example_word = 'YELLOW'
    m = re.match(pattern, example_word)
    print m.group(0)
    

