title: Error with Python dictionary: str object has no attribute append
body: <p>I am writing code in python.
  My input line is "all/DT remaining/VBG all/NNS of/IN "</p>
  
  <p>I want to create a dictionary with one key and multiple values
  For example - all:[DT,NNS]</p>
  
  <pre><code>groupPairsByKey={}
  Code:
  for line in fileIn:
      lineLength=len(line)
      words=line[0:lineLength-1].split(' ')
      for word in words:
          wordPair=word.split('/')
                    if wordPair[0] in groupPairsByKey:
                      groupPairsByKey[wordPair[0]].append(wordPair[1])
  &lt;getting error here&gt;
                    else:
                      groupPairsByKey[wordPair[0]] = [wordPair[1]]
  </code></pre>