title: BeautifulSoup in Python - getting the n-th tag of a type
body: <p>I have some html code that contains many <code>&lt;table&gt;</code>s in it.</p>
  
  <p>I'm trying to get the information in the second table. Is there a way to do this without using <code>soup.findAll('table')</code> ?</p>
  
  <p>When I do use <code>soup.findAll('table')</code>, I get an error:</p>
  
  <pre><code>ValueError: too many values to unpack
  </code></pre>
  
  <p>Is there a way to get the n-th tag in some code or another way that does not require going through all the tables? Or should I see if I can add titles to the tables? (like <code>&lt;table title="things"&gt;</code>)</p>
  
  <p>There are also headers (<code>&lt;h4&gt;title&lt;/h4&gt;</code>) above each table, if that helps.</p>
  
  <p>Thanks.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here's what I was thinking when I asked the question:</p>
  
  <p>I was unpacking the objects into two values, when there were many more. I thought this would just give me the first two things from the list, but of course, it kept giving me the error mentioned above. I was unaware the return value was a list and thought it was a special object or something and I was basing my code off of my friends'.</p>
  
  <p>I was thinking this error meant there were too many tables on the page and that it couldn't handle all of them, so I was asking for a way to do it without the method I was using. I probably should have stopped assuming things.</p>
  
  <p>Now I know it returns a list and I can use this in a for loop or get a value from it with <code>soup.findAll('table')[someNumber]</code>. I learned what unpacking was and how to use it, as well. Thanks everyone who helped.</p>
  
  <p>Hopefully that clears things up, now that I know what I'm doing my question makes less sense than it did when I asked it, so I thought I'd just put a note here on what I was thinking.</p>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>This question is now pretty old, but I still see that I was never really clear about what I was doing.</p>
  
  <p>If it helps anyone, I was attempting to unpack the <code>findAll(...)</code> results, of which the amount of them I didn't know.</p>
  
  <pre><code>useless_table, table_i_want, another_useless_table = soup.findAll("table");
  </code></pre>
  
  <p>Since there weren't always the amount of tables I had guessed in the page, and all the values in the tuple need to be unpacked, I was receiving the <code>ValueError</code>:</p>
  
  <pre><code>ValueError: too many values to unpack
  </code></pre>
  
  <p>So, I was looking for the way to grab the second (or whichever index) table in the tuple returned without running into errors about how many tables were used.</p>