import math


def tfIDF(word, word_dict):
    """Takes a word and the dictionary from the search index query from that
    word and returns a new word dictionary formatted with TF.IDF scores for
    each chapter. 
    ----------
    Parameters: 
    word (string): the queried word
    word_dict (dict): the dictionary produced by the query
    ----------
    Returns: 
    tfidf_dict (dict): the word_dict modified to include TF.IDF scores in
    the keys 
    """
    IDF = math.log(64/len(word_dict), 2)
    tfidf_dict = {}
    for key, val in word_dict.items():
        tf_idf = round(len(val) * IDF, 3)
        new_key = key + ' (TF*IDF = ' + str(tf_idf) + ')'
        tfidf_dict[new_key] = val
        
    return tfidf_dict