Strange merging - list of words
<p>I have a list of lists of words like this:</p>

<pre><code>texts=[['word1', 'word2', 'word3']['word4', 'word5', 'word6']]
</code></pre>

<p>My desired output would be:</p>

<pre><code>texts=[['word1 word2 word3']['word4 word5 word6']
</code></pre>

<p>This is what I tried:</p>

<p>for item in texts:</p>

<pre><code>item=[" ".join([word for word in item])]
</code></pre>

<p>But it doesn't work. Why?</p>

<p>Just pass the sub lists to <code>join</code>:</p>

<pre><code>In [62]: [[' '.join(sub_list)] for sub_list in texts]
Out[62]: [['word1 word2 word3'], ['word4 word5 word6']]
</code></pre>

python list