title: How to use for loop inside dictionary
body: <p>Can anyone please explain the below implementation:</p>
  
  <pre><code>item = dict((i.tag, (type(i.text) == str and i.text.strip() or i.text)) for i in r if i.tag != "tid_item")
  </code></pre>
  
  <p>The values I am getting in various variables:</p>
  
  <pre><code>r is something like : &lt;Element 'Rows' at 0x0000000003DA4540&gt;
  i.tag : resultNum
  i : &lt;Element 'resultNum' at 0x0000000003EA45A0&gt;
  i.text : 1
  </code></pre>
  
  <p>I am python novice and I am unable to understand how forloop is used within dictionary as values are also absurd.</p>
  
  <p>Thanks for help!</p>