Question: Python: write a function that takes a word and the name of a dictionary file, and then returns a list of all the entires from
Python: write a function that takes a word and the name of a dictionary file, and then returns a list of all the entires from the dictionary that Gematrically match the given word.
Below is the framework for the function to be finished. It includes the parameters we are to pass through the function, what Gematria is and doc string examples of how it should work. Your code should start at and replace the word 'pass':
---------------------------
def gematria(word_to_match, filename): """ Takes a word and the name of a dictionary file, and then returns (a list of) all the entries from the dictionary that Gematrically match the given word. "Gematria is the act of assigning numeric values to letters in an alphabet" -- (https://en.wikipedia.org/wiki/Gematria, last access 10/7/2017). Once each letter is assigned a value you can compute the value of a word or phrase by simply summing the values of each letter in the word/phrase. Using a mapping of a=1, b=2, c=3, ..., z=26, "Phil" has a value of P=16 + h=8 + i=9 + l=12 == 45. Note that the case of a letter does not change its value. :param word_to_match: the word for which you are trying to find a Gematric match :param filename: the dictionary file containing other candidate words >>> gematria('Phil', 'small_dict.txt') ['bios', 'coder', 'gore', 'knife', 'racer'] """ # replace pass below with your code pass Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
