title: Loop Through Table Rows Using BeautifulSoup
body: <p>I need help looping through table rows and putting them into a list.  On this website, there are three tables, each with different statistics - <a href="http://www.fangraphs.com/statsplits.aspx?playerid=15640&amp;position=OF&amp;season=0&amp;split=0.4" rel="nofollow noreferrer">http://www.fangraphs.com/statsplits.aspx?playerid=15640&amp;position=OF&amp;season=0&amp;split=0.4</a> </p>
  
  <p>For instance, these three tables have rows for 2016, 2017, and a total row.  I would like the following:</p>
  
  <p>A list of the following -->table 1 - row 1, table 2 - row 1, table 3 - row 1
  A second list of the following -->table 1 - row 2, table 2 - row 2, table 3 - row 2
  A third list: -->table 1 - row 3, table 2 - row 3, table 3 - row 3</p>
  
  <p>I know I obviously need to create lists, and need to use the append function; however, I am not sure how to get it to loop through just the first row of each table, then the second row of each table, and etc through each row of the table (the number of rows will vary in each instance - this one just happens to have 3).</p>
  
  <p>Any help is greatly appreciated.  The code is below:</p>
  
  <pre><code>from bs4 import BeautifulSoup
  import requests
  import pandas as pd
  import csv
  
  idList2 = ['15640', '9256']
  splitList=[0.4,0.2,0.3,0.4]
  for id in idList2:
      pos = 'OF'
      for split in splitList:
          url = 'http://www.fangraphs.com/statsplits.aspx?playerid=' + 
              str(id) + '&amp;position=' + str(pos) + '&amp;season=0&amp;split=' + 
              str(split) + ''
          r = requests.get(url)
  
          for season in range(1,4):
              print(season)
              soup = BeautifulSoup(r.text, "html.parser")
              tableStats = soup.find("table", {"id" :  "SeasonSplits1_dgSeason" + str(season) + "_ctl00"})
              soup.findAll('th')
              column_headers = [th.getText() for th in soup.findAll('th')]                      
              statistics = soup.find("table", {"id" :                     
  '"SeasonSplits1_dgSeason" + str(season) + "_ctl00"})'
              tabledata = [td.getText() for td in statistics('td')]                         
              print(tabledata)
  </code></pre>