<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">I made this program but it says that there is an error and I have a hard time trying to solve the problem with program. Here is the program:<br><br><br>#this reads all of the words in the file into a list<br>infile = open('/afs/cats/courses/cmps012a-cm/pa1/wordList.txt')<br>wdcount = int(infile.readline()) #first item is count of all the words<br>word_list = infile.readlines()<br><br>#print them out from the internal list<br>i = 0<br>while i &lt; wdcount:<br>&nbsp;&nbsp;&nbsp; print word_list[i],<br>&nbsp;&nbsp;&nbsp; i = i + 1<br><br>#map of alphabet to prime numbers with respect to frecuency<br>#more frequent the letter the smaller the assigment prime<br>letter_to_prime = {<br>&nbsp;&nbsp;&nbsp; 'a':7,<br>&nbsp;&nbsp;&nbsp; 'b':59,<br>&nbsp;&nbsp;&nbsp; 'c':29,<br>&nbsp;&nbsp;&nbsp; 'd':31,<br>&nbsp;&nbsp;&nbsp; 'e':2,<br>&nbsp;&nbsp;&nbsp;
 'f':67,<br>&nbsp;&nbsp;&nbsp; 'g':41,<br>&nbsp;&nbsp;&nbsp; 'h':53,<br>&nbsp;&nbsp;&nbsp; 'i':3,<br>&nbsp;&nbsp;&nbsp; 'j':97,<br>&nbsp;&nbsp;&nbsp; 'k':73,<br>&nbsp;&nbsp;&nbsp; 'l':23,<br>&nbsp;&nbsp;&nbsp; 'm':47,<br>&nbsp;&nbsp;&nbsp; 'n':13,<br>&nbsp;&nbsp;&nbsp; 'o':19,<br>&nbsp;&nbsp;&nbsp; 'p':43,<br>&nbsp;&nbsp;&nbsp; 'q':101,<br>&nbsp;&nbsp;&nbsp; 'r':11,<br>&nbsp;&nbsp;&nbsp; 's':5,<br>&nbsp;&nbsp;&nbsp; 't':17,<br>&nbsp;&nbsp;&nbsp; 'u':37,<br>&nbsp;&nbsp;&nbsp; 'v':71,<br>&nbsp;&nbsp;&nbsp; 'w':79,<br>&nbsp;&nbsp;&nbsp; 'x':89,<br>&nbsp;&nbsp;&nbsp; 'y':61,<br>&nbsp;&nbsp;&nbsp; 'z':83},<br><br>j = 0<br>while j &lt; wdcount:<br>&nbsp;&nbsp;&nbsp; print word_list [j],<br>&nbsp;&nbsp;&nbsp; prod = 1<br>&nbsp;&nbsp;&nbsp; i = 0<br>&nbsp;&nbsp;&nbsp; while i &lt; len(word_list[j])-2:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prod = prod * letter_to_prime[word_list[j] [i]:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = i +
 1<br>&nbsp;&nbsp;&nbsp; print prod (right here is where it says that there's an error I try to fix it )<br>&nbsp;&nbsp;&nbsp; j = j =1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br># code that will be compared will be a histogram type code with frequency<br># characters<br>def code(w):<br>&nbsp;&nbsp;&nbsp; hist = []<br>&nbsp;&nbsp;&nbsp; chars = list(w) <br>&nbsp;&nbsp;&nbsp; chars.sort() <br>&nbsp;&nbsp;&nbsp; for letter in chars: <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if not letter in hist:&nbsp; # when the letter is not already in hist, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hist.extend([letter, str(w.count(letter))])&nbsp; # its added to hist along with its freq.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:
 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; continue<br>&nbsp;&nbsp;&nbsp; coding = "".join(hist) # then they are joined as one string<br>&nbsp;&nbsp;&nbsp; return coding<br><br><br><br><br># new list is made with words in word_list followed by its code<br>for word in&nbsp; word_list:<br>&nbsp;&nbsp;&nbsp; wordList.append(word) <br>&nbsp;&nbsp;&nbsp; wordList.append(code(word[:(len(word)-2)])) <br><br><br>while True:<br>&nbsp;&nbsp;&nbsp; word1 = raw_input('Enter word:') <br>&nbsp;&nbsp;&nbsp; word = word1.lower() <br>&nbsp;&nbsp;&nbsp; sig = code(word) <br>&nbsp;&nbsp;&nbsp; i = 1 <br>&nbsp;&nbsp;&nbsp; if sig in wordList: <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "Anagrams:"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while i &lt;= len(wordList):&nbsp; # when the sig of the inputed word is in the word list, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if sig ==
 wordList[i]:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print wordList[i-1]&nbsp; # the corresponding words are printed<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i += 2 # then adds two because codes are every other entry<br>&nbsp;&nbsp;&nbsp; else:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "No anagrams"<br>&nbsp;&nbsp;&nbsp; choice = raw_input("Continue? (yes/no)")<br>&nbsp;&nbsp;&nbsp; if choice == 'y' or choice == 'yes':<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; continue<br>&nbsp;&nbsp;&nbsp; else:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break<br>I don't know how to figure out the error since the only message that I get is that "there's an error: invalid syntax"<br><br></td></tr></table><br>