title: Converting list of lists of lists into dictionary of dictionaries (Python)
body: <p>Suppose I have a list <code>X =  [[[2, 2]], [[2, 5], [3, 1]], [[3, 3], [4, 4], [1, 6]], [[1, 1], [4, 0]], [[]]]</code>. I want to convert <code>X</code> into a dictionary of dictionaries like so.</p>
  
  <pre><code>G = {0: {2: 2},
       1: {2: 5, 3: 1},
       2: {3: 3, 4: 4, 1: 6},
       3: {1: 1, 4: 0},
       4: {}
      }
  </code></pre>
  
  <p>So far I have</p>
  
  <pre><code>for i in range(0,len(X)):
      for j in range(0, len(X[i])):
          G[i] = {X[i][j][0]: X[i][j][1]}
  </code></pre>
  
  <p>which produces</p>
  
  <pre><code>{0: {2: 2}}
  {0: {2: 2}, 1: {2: 5}}
  {0: {2: 2}, 1: {3: 1}}
  {0: {2: 2}, 1: {3: 1}, 2: {3: 3}}
  {0: {2: 2}, 1: {3: 1}, 2: {4: 4}}
  {0: {2: 2}, 1: {3: 1}, 2: {1: 6}}
  {0: {2: 2}, 1: {3: 1}, 2: {1: 6}, 3: {1: 1}}
  {0: {2: 2}, 1: {3: 1}, 2: {1: 6}, 3: {4: 0}}
  Traceback (most recent call last):
  G[i] = {X[i][j][0]: X[i][j][1]}
  IndexError: list index out of range
  </code></pre>
  
  <p>First it only updates the dictionaries instead of appending new keys, second it fails me at my empty list.<br>
  Any suggestions?</p>