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 tried to codify your question:</p>

<pre><code>ei = [[Enemy(), Enemy()][Enemy2()]]
for wave in ei:
    if self In wave:
        print(ei.index(self))
</code></pre>

<p>What do you mean by <code>[[Enemy(), Enemy()][Enemy2()]]</code>?
You are trying to get the <code>Enemy2()</code>th element of <code>[Enemy(), Enemy()]</code> which is meaningless (<strong>Type Error</strong>).</p>

<p>You are also creating recursively <code>Enemy</code> / <code>Enemy2</code> objects (assuming this code is in <code>__init__</code>) (<strong>Maximum Recursive Depth Error</strong>), and checking if <code>self</code> is in the objects you have just created, when these elements are not even <code>Enemy</code> or <code>Enemy2</code> typed (<strong>another Type error</strong>).</p>

<p>And the <code>In</code> in line 3 <strong>must</strong> give you an error (<strong>Syntax Error</strong>). You can not run this code, so if you got <code>None</code> instead of detailed traceback, you should go get a new debugger.</p>

python list nested-lists