title: Using BeautifulSoup, how to guard against elements not being found?
body: <p>I am looping through table rows in a table, but the first 1 or 2 rows doesn't have the elements I am looking for (they are for table column headers etc.).</p>
  
  <p>So after say the 3rd table row, there are elements in the table cells (td) that have what I am looking for.</p>
  
  <p>e.g.</p>
  
  <pre><code>td[0].a.img['src']
  </code></pre>
  
  <p>But calling this fails since the first few rows don't have this.</p>
  
  <pre><code>How can I guard against these cases so my script doesn't fail?
  </code></pre>
  
  <p>I get errors like:</p>
  
  <pre><code>nonetype object is unsubscriptable
  </code></pre>