title: Dictionary comprehension with conditional
body: <p>So I'm wondering if anyone can help me out with this issue I'm having.</p>
  
  <p>Lets assume I have a dictionary:</p>
  
  <pre><code>d = {1: {2: 3}, 4: 5}
  </code></pre>
  
  <p>I want to create a dictionary of any contained dictionaries:</p>
  
  <pre><code>wanted_result = {2: 3}
  </code></pre>
  
  <p>what I am trying is this:</p>
  
  <pre><code>e = {inner_key: d[key][inner_key] for key in d.keys() for inner_key in d[key].keys() if isinstance(d[key], dict)}
  </code></pre>
  
  <p>However this is causing me to get an error saying that ints don't have keys, which I know, but I thought my conditional would exclude say 4 from my example from being included in the comprehension.</p>