How do i get list instead of list of list?
<p>I am trying to read a text file with the following format <code>"a b c d e f g h"</code>. I take a new empty list <code>word = []</code></p>

<p>My code is:</p>

<pre><code>f = open("letters.txt")

word = []

for line in f:
    line = line.split(" ")
    word.append(line)
print(word)
</code></pre>

<p>However, it has given me a list of list like this:</p>

<pre><code>[['a', 'b', 'c', 'd', 'e', 'f']]
</code></pre>

<p>But I want to get it in a single list instead?</p>

<p>eg:</p>

<pre><code>['a', 'b', 'c']
</code></pre>

<p>@Rahul's answer is correct. But this should help you understands when not to use <code>append</code></p>

<p><code>append(x)</code> adds x as a new element on the end of the list. It doesn't matter what x is <code>extend</code> would have worked.</p>

<pre><code>&gt;&gt;&gt; l = []
&gt;&gt;&gt; l.append(1)
&gt;&gt;&gt; l.append('a')
&gt;&gt;&gt; l.append({1,2,3})
&gt;&gt;&gt; l.append([1,2,3])
&gt;&gt;&gt; l
[1, 'a', set([1, 2, 3]), [1, 2, 3]]
&gt;&gt;&gt; 
&gt;&gt;&gt; 
&gt;&gt;&gt; l = []
&gt;&gt;&gt; l.extend(1)
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
TypeError: 'int' object is not iterable
&gt;&gt;&gt; l.extend([1])
&gt;&gt;&gt; l.extend([4,5,6])
&gt;&gt;&gt; l
[1, 4, 5, 6]
</code></pre>

python list readfile