create a list but getting a string?
<pre><code>s = """
1:A,B,C,D;E,F
2:G,H;J,K
&amp;:L,M,N
"""

def read_nodes(gfile):
    for line in gfile.split():
        nodes = line.split(":")[1].replace(';',',').split(',')
        for node in nodes:
            print node

print read_nodes(s)
</code></pre>

<p>I am expected to get <code>['A','B','C','D','E',.....'N']</code>, but I get <code>A B C D E .....N</code> and it's not a list. I spent a lot of time debugging, but could not find the right way.</p>

<p>Add the following code so that the output is
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N'] </p>

<pre><code>//Code to be added
nodes_list = []

def read_nodes(gfile):

    for line in gfile.split():
        nodes =line.split(":")[1].replace(';',',').split(',')
        nodes_list.extend(nodes)
    print nodes_list

print read_nodes(s)
</code></pre>

python list debugging