How to reconstruct a list with punctuation into a sentence? In python 3.5
<p>I have a list e.g. <code>['hello',', ','how','are','you','?']</code> and i want it to become <code>"hello, how are you?"</code>
Is there anyway at doing this?</p>

<p>I should also note that i am opening this from a text document, using the code:</p>

<pre><code>    with gzip.open('task3.txt.gz', 'r+') as f:
    reconstruct = f.readline()
    reconstruct2 = f.readline()
    reconstruct3 = f.readline()
    reconstruct4 = f.readline()
    f.close()
</code></pre>

<p>So my lists come out as <code>b'["hello", ",", "how", "are", "you", "?"]\n'</code> could this be linked to the fact i saved them with new lines?</p>

<p>I believe, you're looking for <strong>join()</strong>:</p>

<pre><code>&gt;&gt;&gt; a = ['hello',', ','how','are','you','?']
&gt;&gt;&gt; " ".join(a)
'hello ,  how are you ?'
</code></pre>

<p>Note, that the content of quotation marks will be inserted in between of your words. So you need to decide, if you want to use " " (which will insert space also between "you" and "?", for example) or "" - but insert space at the end of each word (your array should look like that: ['Hello', ', ', 'how ', 'are ', 'you', '?'])</p>

python python-3.x