Hello,
I am writing a "scrabble code" on Python. I have some problem with getting possible words from the given letters. For example:
Given letters are: 'c', 'r', 'n', '*'
Here '*' can be any letter.
Possible words: 'cry', 'corn', 'run', etc.
proper_word_lis t is a file containing all the english words.
score_of_word is a function that computes the score of the word.
hand is the letters that are given to the player
Following is my code (it gets only the possible words without star in hand):
Thank you in advance.
I am writing a "scrabble code" on Python. I have some problem with getting possible words from the given letters. For example:
Given letters are: 'c', 'r', 'n', '*'
Here '*' can be any letter.
Possible words: 'cry', 'corn', 'run', etc.
proper_word_lis t is a file containing all the english words.
score_of_word is a function that computes the score of the word.
hand is the letters that are given to the player
Following is my code (it gets only the possible words without star in hand):
Code:
def get_possible_words(hand, proper_word_list, score_of_a_letter_list) :
possible_words = []
for j in range(len(proper_word_list)):
k = list(proper_word_list[j])
k.sort()
c = "".join(k)
d = list(hand)
d.sort()
m = "".join(d)
if c in m:
l = (score_of_word(c, score_of_a_letter_list), proper_word_list[j])
possible_words.append(l)
possible_words.sort()
possible_words.reverse()
return possible_words
Thank you in advance.
Comment