List of Lists: finding a value throughout
<p>I am using Python to write a program that looks through lists of lists and changes values.</p>

<p>In my list of lists I have 3's and I want to find their index. Right now I can only get it to work on the first row. I want it to find 3's on any of the lists in "numbers."</p>

<p>Here is some sample code to wash away the mud:</p>

<pre><code>numbers = [
    [3, 3, 3, 5, 3, 3, 3, 3, 6],
    [8, 0, 0, 0, 4, 7, 5, 0, 3],
    [0, 5, 0, 0, 0, 3, 0, 0, 0],
    [0, 7, 0, 8, 0, 0, 0, 0, 9],
    [0, 0, 0, 0, 1, 0, 0, 0, 0],
    [9, 0, 0, 0, 0, 4, 0, 2, 0],
    [0, 0, 0, 9, 0, 0, 0, 1, 0],
    [7, 0, 8, 3, 2, 0, 0, 0, 5],
    [3, 0, 0, 0, 0, 8, 0, 0, 0],
    ]
a = -1
while a:
    try:
        for row in numbers:
            a = row[a+1:].index(3) + a + 1
            print("Found 3 at index", a)
    except ValueError:
        break
</code></pre>

<p>When I run it I get:</p>

<pre><code>Found 3 at index 0
Found 3 at index 1
Found 3 at index 2
Found 3 at index 4
Found 3 at index 5
Found 3 at index 6
Found 3 at index 8
</code></pre>

<p>Which shows that it is working but only on the first row.</p>

<p>Thanks!</p>
