Note that there are some explanatory texts on larger screens.

plurals
  1. POIterating over multiple lists in Python
    primarykey
    data
    text
    <p>I have a list within a list, and I am trying to iterate through one list, and then in the inner list I want to search for a value, and if this value is present, place that list in a variable.</p> <p>Here's what I have, which doesn't seem to be doing the job:</p> <pre><code>for z, g in range(len(tablerows), len(andrewlist)): tablerowslist = tablerows[z] if "Andrew Alexander" in tablerowslist: andrewlist[g] = tablerowslist </code></pre> <p>Any ideas?</p> <p>This is the list structure:</p> <pre><code>[['Kyle Bazzy', 'FUP dropbox message', '8/18/2011', 'Swing Trade Stocks&lt;/a&gt;', '&amp;nbsp;', 'Affiliate blog'], ['Kyle Bazzy', 'FUP dropbox message', '8/18/2011', 'Swing Trade Software&lt;/a&gt;', '&amp;nbsp;', 'FUP from dropbox message. Affiliate blog'], ['Kyle Bazzy', 'FUP dropbox message', '8/18/2011', 'Start Day Trading (Blog)&lt;/a&gt;', '&amp;nbsp;', 'FUP from dropbox message'], ['Kyle Bazzy', 'Call, be VERY NICE', '8/18/2011', '&amp;nbsp;', 'r24867&lt;/a&gt;', 'We have been very nice to him, but he wants to cancel, we need to keep being nice and seeing what is wrong now.'], ['Jason Raznick', 'Reach out', '8/18/2011', 'Lexis Nexis&lt;/a&gt;', '&amp;nbsp;', '-'], ['Andrew Alexander', 'Check on account in one week', '8/18/2011', '&amp;nbsp;', 'r46876&lt;/a&gt;', '-'], ['Andrew Alexander', 'Cancel him from 5 dollar feed', '8/18/2011', '&amp;nbsp;', 'r37693&lt;/a&gt;', '-'], ['Aaron Wise', 'FUP with contract', '8/18/2011', 'YouTradeFX&lt;/a&gt;', '&amp;nbsp;', "Zisa is on vacation...FUP next week and then try again if she's still gone."], ['Aaron Wise', 'Email--JASON', '8/18/2011', 'Lexis Nexis&lt;/a&gt;', '&amp;nbsp;', 'email by today'], ['Sarah Knapp', '3rd FUP', '8/18/2011', 'Steven L. Pomeranz&lt;/a&gt;', '&amp;nbsp;', '-'], ['Sarah Knapp', 'Are we really interested in partnering?', '8/18/2011', 'Reverse Spins&lt;/a&gt;', '&amp;nbsp;', "V. political, doesn't seem like high quality content. Do we really want a partnership?"], ['Sarah Knapp', '2nd follow up', '8/18/2011', 'Business World&lt;/a&gt;', '&amp;nbsp;', '-'], ['Sarah Knapp', 'Determine whether we are actually interested in partnership', '8/18/2011', 'Fayrouz In Dallas&lt;/a&gt;', '&amp;nbsp;', "Hasn't updated since September 2010."], ['Sarah Knapp', 'See email exchange w/Autumn; what should happen', '8/18/2011', 'Graham and Doddsville&lt;/a&gt;', '&amp;nbsp;', "Wasn't sure if we could partner bc of regulations, but could do something meant simply to increase traffic both ways."], ['Sarah Knapp', '3rd follow up', '8/18/2011', 'Fund Action&lt;/a&gt;', '&amp;nbsp;', '-']] </code></pre> <p>For any value that has a particular value in it, say, Andrew Alexander, I want to make a separate list of these.</p> <p>For example:</p> <pre><code>[['Andrew Alexander', 'Check on account in one week', '8/18/2011', '&amp;nbsp;', 'r46876&lt;/a&gt;', '-'], ['Andrew Alexander', 'Cancel him from 5 dollar feed', '8/18/2011', '&amp;nbsp;', 'r37693&lt;/a&gt;', '-']] </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload