code: def predictive_text(dic):
      
      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
docs: 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