How can I extract these list and tuples into strings?
<p>I have these lists and tuples and can't figure out how to extract the numbers out of them.</p>

<pre><code>[('40', '50')] [('35', '45', '49')] [('02', '11')]
</code></pre>

<p>They are stored in three different variables, how can I extract them? I've tried the following:</p>

<pre><code>chain.from_iterable(list_one)
</code></pre>

<p>but it gives me this:</p>

<pre><code>&lt;itertools.chain object at 0x1101415f8&gt;
</code></pre>

<p>Expected output for <code>[('40', '50')]</code> is <code>40 50</code></p>

<p>Expected output for <code>[('35', '45', '49')]</code> is <code>35 45 49</code></p>

<p>Expected output for <code>[('02', '11')]</code> is <code>02 11</code></p>

<p>Use <strong><a href="https://docs.python.org/3/library/itertools.html#itertools.chain" rel="nofollow"><code>chain</code></a></strong> to chain your lists together and then iterate through them. Then you can unpack in the <code>print</code> call to get every sub-element element printed out.</p>

<p>So, if for example your lists are named <code>l1</code>, <code>l2</code> and <code>l3</code> as so:</p>

<pre><code>l1, l2, l3 = [('40', '50')], [('35', '45', '49')], [('02', '11')]
</code></pre>

<p>You're able to access each individual and print it with:</p>

<pre><code>for sub in chain(l1, l2, l3):
    print(*sub)
</code></pre>

<p>Yields:</p>

<pre><code>40 50
35 45 49
02 11
</code></pre>

<p>Now, the output from your original attempt, namely:</p>

<pre><code>&lt;itertools.chain object at 0x1101415f8&gt;
</code></pre>

<p>is due to the fact that <code>chain</code> returns an <em>iterator</em> object and that is its representation in the Python REPL. Remember, iterators are meant to be iterated over.</p>

python python-3.x