title: when i try to append value in dict its showing key error
body: <p>I have a css file of this type</p>
  
  <pre><code>col1    col2
  AAA       
   a        1
    a1      1
    a2      1
   b        1
    b1      1
    b2      1
  </code></pre>
  
  <p>i am reading first col based on indentation,"AAA" has 0 no of spaces,"a" "b" has 1 space and "a1","a2" "b1" "b2" has 2 space, now i am printing dict as</p>
  
  <pre><code>d={'a':['a1','a2'],'b':['b1','b2']}
  </code></pre>
  
  <p>But what i want is </p>
  
  <pre><code>d={'AAA':['a','b'],'a':['a1','a2'],'b':['b1','b2']}
  </code></pre>
  
  <p>i am using code like this</p>
  
  <pre><code>reader=csv.DictReader(open("c:/Users/Darshan/Desktop/sss.csv"),dialect="excel")
  for row in reader:
      a.append(row['col1'])
      for i in range(len(a)):
          if a[i].count(' ')==1:
              d[a[i]]=[]
              k=a[i]
  
          else a[i].count(' ')==2:
              d[k].append(a[i])
  </code></pre>
  
  <p>this print this output</p>
  
  <pre><code> d={'a':['a1','a2'],'b':['b1','b2']}
  </code></pre>
  
  <p>so can anyone help me,thanks in advance</p>