<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def predictive_text(dic):
 """Predictive text for mobile phones :param dic: associates weights to words from [a-z]* :returns: a dictionary associating to words from [2-9]* a corresponding word from the dictionary with highest weight :complexity: linear in total word length """

    freq = {}   # freq[p] = total weight of words having prefix p
    for word, weight in dic:
        prefix = ""
        for x in word:
            prefix += x
            if prefix in freq:
                freq[prefix] += weight
            else:
                freq[prefix] = weight
    #   prop[s] = prefix to display for s
    prop = {}
    for prefix in freq:
        code = code_word(prefix)
        if code not in prop or freq[prop[code]] < freq[prefix]:
            prop[code] = prefix
    return prop