Adding returned tuples to a list of lists
<p>I am trying to add the returned tuples to a list of lists or list of arrays.</p>

<pre><code>    dim = 10
    for key, figure in sorted(problem.figures.iteritems(), reverse=True):
        dim -= 1
        # print key, dim 
        (img_arr[dim], images[dim]) = vectorize(figure)
</code></pre>

<p>The function returns an array and an image. I am trying to create a list of arrays and a list of images. Can I do this without initializing a list of images outside of the loop?</p>

<p>Try using <code>append()</code> attribute of list like this:</p>

<pre><code>img_arr, images = [],[] # assuming you already declared the list

for key, figure in sorted(problem.figures.iteritems(), reverse=True):
     tup = vectorize(figure)
     img_arr.append(tup[0])
     images.append(tup[1])
</code></pre>

<blockquote>
  <p>The method append() appends a passed obj into the existing list.</p>
</blockquote>

python list