What am I missing to me they are essentially the same thing. One is my solution the other is Google's which both solve the same problem. However I keep noticing that the Google version is somehow twice as fast as mine. What am I missing?
#mimic dictionary
"""
    match each word in a string to a list of words that will follow it
    example:
        "hi my name is chris, hi chris, hi how are you"
        {hi: ["my","chris","how"], my: ["name"],...}
"""
def mimic_dict(str):
    list1 = str.split()
    dict = {}
    index, end = 0,  len(list1) - 1
    while index < end:
        current, next = list1[index], list1[index + 1]
        if not current in dict:
            dict[current] = [next]
        else:
            dict[current].append(next)
        index += 1 
    return dict
#google    
def mimic_dict1(text):
  mimic_dict = {}
  words = text.split()
  prev = ''
  for word in words:
    if not prev in mimic_dict:
      mimic_dict[prev] = [word]
    else:
      mimic_dict[prev].append(word)
    prev = word
  return mimic_dict
 
    