How to access values of list inside list- Python
<p>I'm trying to make a game using pygame but I'm having problems with lists inside other lists.</p>

<p>inside the class of Enemy/Enemy 2 i have the following code:</p>

<pre><code>ei = [[Enemy(), Enemy()][Enemy2()]]

for wave in ei:
    if self in wave:
        print(ei.index(self))
</code></pre>

<p>The object is inside the list, I have checked by printing out <code>ei</code> in bulk, however this code just returns 'None'.</p>

<p>I tried to <code>print('True')</code> instead of the index, however it still prints <code>None</code></p>

<p>I am guessing, and there are several problems in your example. But maaaybe you want this:</p>

<pre><code>for index, wave in enumerate(ei):
    if self in wave:
        print(index)
</code></pre>

<p>See my comments or elaborate your question --as already recommended by other users, provide a MCVE and fix/explain the variables and classes.</p>

python list nested-lists