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>Or you can try this:</p>

<pre><code>list=[["o","o","o"],["o","i","o"],["o","o","o"]]
f = [sublist for sublist in list if element in sublist][0]
print(list.index(f), f.index(element))
</code></pre>

<p>That <code>[0]</code> is because it will return something like <code>[[a,b]]</code>, because is  like a filter. But I need <code>[a, b]</code>. Hope it helps. The problem with this is that it fails when the element isn't in list.</p>

python list python-3.x