Get the index of a unique character in a table (list of lists)?
<p>I have a list of r lists of r elements each.
Let's say <code>r=3</code> then I have something that looks like this:</p>

<pre><code>list=[["o","o","o"],["o","i","o"],["o","o","o"]]
</code></pre>

<p>I would like, using the method """<code>list.index(item)</code>""", to get the index of the "i" elements inside this list. So as a result I should get something I imagine like (x,y) with x for the xth sublist and y for the yth element inside the xth sublist ((1,1) in this case).</p>

<p>I can join the code of my program (game) if you need it later. </p>

<p>You could <code>try</code> to find the index row by row:</p>

<pre><code>def findI(rows):
    for i,row in enumerate(rows):
        try:
            return (i,row.index("i"))
        except ValueError:
            pass
</code></pre>

<p>For example:</p>

<pre><code>&gt;&gt;&gt; x =[["o","o","o"],["o","i","o"],["o","o","o"]]
&gt;&gt;&gt; findI(x)
(1, 1)
</code></pre>

python list python-3.x