Flattening arbitrarily deep nested lists : <p>I want to retrieve data from n nested lists in Python. That is:</p>

<pre><code>[[[[[1, 2]]]]] =&gt; [1, 2]
</code></pre>

<p>I could obviously do something like:</p>

<pre><code>mylist[0][0][0][0]
</code></pre>

<p>But I'm wondering if there is a way to do this without having to know how deep the nesting of the list is. </p>

<p>I want to do this because I have got some fairly malformed data from a REST API request which needs processing. </p>
