title: Can't index a dict in a list comprehension
body: <p>I'm attempting to extract a <code>list</code> from a <code>list</code> of <code>dict</code>s.
  Each <code>dict</code> in the list has a single key-value mapping. I want to create a <code>list</code> of that single value mapped in each <code>dict</code> contained by the <code>list</code>.</p>
  
  <p>See below the code and output, written in an interactive form.</p>
  
  <pre><code>&gt;&gt;&gt; print(str(param_to_outputs_dict_dict))
  {('max_features', 1558): {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=1558, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}, 
  ('max_features', 7713): {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=7713, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  &gt;&gt;&gt; print()
  </code></pre>
  
  <p>Above we see that <code>param_to_outputs_dict_dict</code> is a <code>dict</code> of two entries. The key for each entry is a <code>tuple</code> and the value is a <code>dict</code>.</p>
  
  <p>Next, I use list comprehension to extract the <code>list</code> of values (of type <code>dict</code>)</p>
  
  <pre><code>&gt;&gt;&gt; map_list = [output_dict for output_dict in list(param_to_outputs_dict_dict.values())]
  &gt;&gt;&gt; print(str(map_list))
  [{'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=1558, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}, 
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=7713, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}]
  &gt;&gt;&gt; print()
  </code></pre>
  
  <p>We see that this worked, also. We have a <code>list</code> containing two <code>dict</code>s, which were the values contained in <code>param_to_outputs_dict_dict</code>.</p>
  
  <p>Now, instead of extracting the dictionaries, I instead attempt to extract the value in each dictionary mapped by the value <code>'classifier'</code>.</p>
  
  <pre><code>&gt;&gt;&gt; classifier_list = [output_dict['classifier'] for output_dict in list(param_to_outputs_dict_dict.values())]
  &gt;&gt;&gt; print(str(classifier_list))
  
  
  ---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-176-b6f236339c69&gt; in &lt;module&gt;()
        8 print(str(map_list))
        9 print()
  ---&gt; 10 classifier_list = [output_dict['classifier'] for output_dict in list(param_to_outputs_dict_dict.values())]
       11 print(str(classifier_list))
       12 print()
  
  &lt;ipython-input-176-b6f236339c69&gt; in &lt;listcomp&gt;(.0)
        8 print(str(map_list))
        9 print()
  ---&gt; 10 classifier_list = [output_dict['classifier'] for output_dict in list(param_to_outputs_dict_dict.values())]
       11 print(str(classifier_list))
       12 print()
  TypeError: 'DecisionTreeClassifier' object is not subscriptable
  </code></pre>
  
  <p>However, this does not work. The error message leads me to think that Python interpreted <code>output_dict</code> as being of type <code>DecisionTreeClassifier</code>, but I have no idea why. I've played with this problem for hours but am completely stumped.</p>
  
  <p>I suspect the solution may be extremely obvious to someone else! Thanks in advance!</p>
  
  <p><strong>EDIT: critical information missing from original post</strong></p>
  
  <p>To make the question shorter and cleaner, I had truncated the printing results to only include the first two elements of any collection. However, after realising the problem (see my answer below), the cause of the problem is extremely obvious when the full list is given. See below, notably the last element of the list.</p>
  
  <pre><code>&gt;&gt;&gt; for value in list(param_to_outputs_dict_dict.values()):
  &gt;&gt;&gt;     print(str(value))
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=10,
          max_features=None, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=100,
          max_features=None, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=-100, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=3, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=-10000, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=7791, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=77, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=100000,
          max_features=None, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=1558, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=1,
          max_features=None, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=3895, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=7713, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=7011, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight='balanced', criterion='gini',
          max_depth=None, max_features=None, max_leaf_nodes=None,
          min_samples_leaf=1, min_samples_split=2,
          min_weight_fraction_leaf=0.0, presort=False, random_state=None,
          splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='random')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=-1000, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=779, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=10000,
          max_features=None, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=-1, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=1000, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=10, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=1000,
          max_features=None, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=10000, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=6232, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=100, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='entropy', max_depth=None,
          max_features=None, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=88, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=-10, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=100000, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  {'classifier': DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=-100000, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')}
  DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,
          max_features=None, max_leaf_nodes=None, min_samples_leaf=1,
          min_samples_split=2, min_weight_fraction_leaf=0.0,
          presort=False, random_state=None, splitter='best')
  </code></pre>