As described in the last entry, I now have a variable called finallist that is a list of lists.  This list of lists gives me all the possible combinations of the letters in my hand, it doesn’t provide it to me in an easily manipulable format.  So, I’m going to change the formatting.

The next function I created is called comboextension().  This function takes my list of lists, and spits out a list of words, where each word is the combination of a list of letters.  My function is shown below.

 

def comboextension(combo):
   wordlist = []
   word = ''
   for alist in combo:
       word = ''       
       for letter in alist:
           word += letter
       wordlist += [word,]
   return wordlist 

 


This function takes in the results of the previous function as its only input.  First it defines a new list as wordlist, and a variable called word which starts out as an empty string.  Then it processes using a for loop, for each list in the results of the combo function, the following steps.  It redefines the word variable as an empty string, and then starts through another for loop that goes through each letter in the list of letters.  It then adds that letter to the empty variable word, and then adds that current combination of letters to the empty wordlist.  Once this function is complete it will not just have created a list of words that were just combinations of the former lists into strings, but also it adds in all smaller possible combinations by going through each list in smaller subsections.  

Important Notes: Something of interest here, is that the combo() and comboextension() were not functions that the problem set asked to be created.  They were functions that I created in order to implement processes I needed to create, and separate, so I could understand them more easily.  Originally the problem expected these items to be processed within the pick_best_word() function.  I didn’t find that doing so, without splitting up some of the tasks, was easy.  So I tried to make it easier for myself.

Up Next Time: Literature and their unexpected influences