title: Python : IndexError: tuple index out of range
body: <p>In python i have this code</p>
  
  <pre><code>if record[0][1]:
  </code></pre>
  
  <p>the problem is.. when mysql does not return anything and thus..</p>
  
  <pre><code>record[0][1]
  </code></pre>
  
  <p>has no data..</p>
  
  <p>this python code fails:</p>
  
  <pre><code>if record[0][1]:
  IndexError: tuple index out of range
  </code></pre>
  
  <p>i simply want it to move on to the "else" statement or simply consider this if statement as .. invalid given that </p>
  
  <pre><code>record[0][1]
  </code></pre>
  
  <p>has no value. or data.. ( incoming stuff from mysql )</p>