Find Possible word by its known letters and letters position

find words containing certain letters
find words with letters in certain positions
find a word with these letters and blanks
find words with at least these letters
find words containing these letters
word guesser from letters
unscramble letters to make words
find a four letter word with these letters

I'm attempting to find a word by its known letters and letters position (similar to a crossword) similar to what crosswordsolver.org does

Example :

input: 
B E _ K

possible words: 
BEAK
BECK
BELK
BERK

I have all possible words (with the same length) in a list. the problem is, i can't find a proper solution to compare user_input to my list.

comparing each index of each word on dictionary to user_input word letters seems to be a solution, however it is not efficient at all.

is there any other way to approach this problem ?

thank you in advance

EDIT : I should add that regex cannot be used as a solution because I'm working with Persian(farsi) words, which uses persian alphabet (similar to arabic)

User input is taken letter by letter and is stored as List. There might be more than 1 missing letter and theWord length can be anything between 1-10

A quick hack

# Save pattern as (char, position) where position starts at 0
pattern = [("B", 0), ("E", 1), ("K", 3)] 

dictionary = ["BEAK", "BECK", "BELK", "BERK"]

def match(word, pattern):
    if len(pattern) > len(word):
        return false

    return all(word[pos] == c for (c, pos) in pattern):

def list_matches(pattern, dictionary):
    for word in dictionary:
        if match(word, pattern):
            print(word)

list_matches(pattern, dictionary)

You can use a Trie data structure and that will be much more efficient.

Find Words that Contain Some Letters in Them - Online Tool, A quick hack # Save pattern as (char, position) where position starts at 0 pattern = [("B", 0), ("E", 1), ("K", 3)] dictionary = ["BEAK", "BECK",  Descramble rack letters, including blank tiles. Same as scrabble, can also add known letters to select parts of words. Backwards Text Converter. Create your own palindromes, or use it to send a friend or family member a "coded" text to decipher. Words That End With. Search for words that end with a certain letter or a specific word.

I suggest that you build a tree with your list of words.

*-+-A
  |
  +-B-+-A
  |   |
      +-B
      |
      +-C
      |
      +-C
      |
      +-E-+-A-+
      |   |   |
              .
              .
              |
              +-K-x ("BEAK")

Searching would be fast and memory consumption low.

If you don't want to start from scratch, you could use the module anytree.

6 Letter Words, Tool to search words that contain a given letter or sequence of letters, pattern search or suit of letters, containing special As many letters as possible (longest words) To find words with letters in certain positions, use the crossword solver. Word Game Helper. Don't look at us as a word cheat, more of a reference tool you and your playmates can use as a way to settle disputes about the validity of any particular word. Our generator will search both UK and US dictionaries to find you the perfect match. Not only that, our word filter will display results by word length for added ease.

Have a look on regular expression package

Something as:

import re
pattern = re.compile('BE.K')
possible_words = [word for word in all_words if re.match(pattern, word)]

would work.

python, is a placeholder for a single letter. * substitutes for a 0 or more letters. Otherwise, use regular letters in the positions you want. Do a word finder search. The Design215 Word Finder is a free utility that unscrambles words, finds anagrams, solves jumbles, finds rhyming words, and helps with Scrabble, crosswords, and other word games. For example, you can find all 6 letter words that start with "d" and end with "n". Find words that rhyme by searching for words that end with the same letters.

Find words that match your pattern., A word generator is a tool that helps you to find words. It generates all possible words from the letters inputted and by doing so, helps the user discover new ones. People use word Scrabble is another classic word game famous all over the world. Your job is to type in all the letters you will use to spell the word. Now the  Xworder provides word search tools designed to help you solve and compose crosswords and other word puzzles, learn new words and have fun! Find words matching patterns; words beginning, ending or containing given letters ("w??d" - "word", "wood"). Use a question mark (?) or a dot (.) for unknown letters. A fun game of building word chains by

Word Generator - Word Games Solver, words for Scrabble ✓ Find all the possible words from your rack letters order also need to know some of the special tips for getting the most points possible! In the advanced options dropdown, you will notice the ability to add extra letters to the solver. For instance, say you want your result to begin with the letter "P" - in this case, you can enter the letter P in the additional letters section and the results will contain those. Anagram Example. ESTRNGI. YDA SRMADE. PSELE. Clue: Downtime

Scrabble Cheat, Find words matching patterns; words beginning, ending or containing given letters Find words that can be built from the given set of letters ("scrabble" - "​laser",  The Letter Sorting Word Generator helps you to make words from letters. It comes with a built-in option of using a pattern to create specific words. This word generator, or rather word maker, is not bound to any specific word game. The Letter Sorting Word Generator can be of great help to find words from letters for competitions, newspaper

Comments
  • Is there always just a single unknown letter in the input? How many words are there in your list of possible words?
  • Could you please add how your user input is stored? How does the user input the undefined character _?
  • Regex can be used with Unicode. Which version of Python are you using?
  • use r'BE.K' for regex pattern and its word for word not word for work in your list comp
  • BE.K was an example, Regex can be implemented for a good solution however, my Dictionary contains Farsi words (similar to Arabic alphabet) so i can not use regex
  • @A.Aminidad The point was use a raw string to save you from from a backslash hell in your regular expression. For example to match a backslash you need two write "\\\\" or just r"\\", because you need to escape both the slash for the regex and the non-raw python string. So that is much easier to read.