title: perform BeautifulSoup operation on list of lists while maintaining structure in python
body: <p>I have a list of beautiful soup object that i am trying to further parse for contents of  cells. My output becomes a list of lists with 3 items on each since the table had 3 columns. </p>
  
  <pre class="lang-html prettyprint-override"><code>file = &lt;html&gt;&lt;p&gt;&lt;center&gt;&lt;h1&gt;  Interference Report  &lt;/h1&gt;&lt;/center&gt;&lt;p&gt;
  &lt;b&gt;  Interference Report Project File:  &lt;/b&gt;C:\Users\ksobon\Documents\test_project_03_ksobon.rvt  &lt;br&gt;  &lt;b&gt;  Created:  &lt;/b&gt;  Monday, May 26, 2014 7:52:32 PM  &lt;br&gt;  &lt;b&gt;  Last Update:  &lt;/b&gt;    &lt;br&gt;
   &lt;p&gt;&lt;table border=on&gt;  &lt;tr&gt;  &lt;td&gt;&lt;/td&gt;  &lt;td ALIGN="center"&gt;A&lt;/td&gt;  &lt;td  ALIGN="center"&gt;B&lt;/td&gt;  &lt;/tr&gt;
  &lt;tr&gt;  &lt;td&gt;  1  &lt;/td&gt;  &lt;td&gt;  Workset1 : Walls : Basic Wall : E103-CON 100mm : id 469021     &lt;/td&gt;  &lt;td&gt;  Workset1 : Furniture : FUR_BoardroomTable10Chairs_gm : Board Room Layout : id   482259  &lt;/td&gt;  &lt;/tr&gt;
  &lt;tr&gt;  &lt;td&gt;  2  &lt;/td&gt;  &lt;td&gt;  Workset1 : Walls : Basic Wall : E103-CON 100mm : id 469021    &lt;/td&gt;  &lt;td&gt;  Workset1 : Walls : Basic Wall : E103-CON 100mm : id 483442  &lt;/td&gt;  &lt;/tr&gt;
  &lt;tr&gt;  &lt;td&gt;  3  &lt;/td&gt;  &lt;td&gt;  Workset1 : Walls : Basic Wall : E103-CON 100mm : id 469060    &lt;/td&gt;  &lt;td&gt;  Workset1 : Furniture : FUR_Sofa_gm : 2100mm : id 475041  &lt;/td&gt;  &lt;/tr&gt;
  &lt;tr&gt;  &lt;td&gt;  4  &lt;/td&gt;  &lt;td&gt;  Workset1 : Walls : Basic Wall : E103-CON 100mm : id 469109   &lt;/td&gt;  &lt;td&gt;  Workset1 : Furniture : FUR_Sofa_gm : 2100mm : id 475273  &lt;/td&gt;  &lt;/tr&gt;
  &lt;tr&gt;  &lt;td&gt;  5  &lt;/td&gt;  &lt;td&gt;  Workset1 : Walls : Basic Wall : E103-CON 100mm : id 469178   &lt;/td&gt;  &lt;td&gt;  Workset1 : Furniture : FUR_Sofa_gm : 2100mm : id 475510  &lt;/td&gt;  &lt;/tr&gt;
  &lt;tr&gt;  &lt;td&gt;  6  &lt;/td&gt;  &lt;td&gt;  Workset1 : Walls : Basic Wall : E103-CON 100mm : id 469178    &lt;/td&gt;  &lt;td&gt;  Workset1 : Furniture : FUR_Sofa_gm : 2100mm : id 482306  &lt;/td&gt;  &lt;/tr&gt;
  &lt;tr&gt;  &lt;td&gt;  7  &lt;/td&gt;  &lt;td&gt;  whatever : Doors : DOR_Single_gm : 800w, 2100h (720Leaf) -  Mark 102B : id 472052  &lt;/td&gt;  &lt;td&gt;  Workset1 : Windows : WIN-ConceptWindowFixed_gm : 1200 H   x 1200 W - Mark 102B : id 472822  &lt;/td&gt;  &lt;/tr&gt;
  &lt;tr&gt;  &lt;td&gt;  8  &lt;/td&gt;  &lt;td&gt;  whatever : Doors : DOR_Single_gm : 800w, 2100h (720Leaf) -  Mark 101A : id 472376  &lt;/td&gt;  &lt;td&gt;  Workset1 : Windows : WIN-ConceptWindowFixed_gm : 1200 H   x 1200 W - Mark 101C : id 472720  &lt;/td&gt;  &lt;/tr&gt;
  &lt;tr&gt;  &lt;td&gt;  9  &lt;/td&gt;  &lt;td&gt;  Workset1 : Windows : WIN-ConceptWindowFixed_gm : 1800 H x  1200 W 2 - Mark 101B : id 472688  &lt;/td&gt;  &lt;td&gt;  Workset1 : Furniture : FUR_Sofa_gm : 2100mm   : id 482306  &lt;/td&gt;  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;p&gt;&lt;b&gt;  End of Interference Report  &lt;/b&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>from BeautifulSoup import BeautifulSoup
      soup = BeautifulSoup(file)
      tag = soup.findAll('tr')</p>
  
  <pre><code>for i in tag:
      txt.append(i.findAll('td'))
  </code></pre>
  
  <p>Now i want to convert each sublist element to text so i tried:
      txt1 = [i.text for x in txt for i in x]
  My output for txt1 however comes out as a flat list instead of list of lists. What am i doing wrong? </p>