read from a text file. - Python
<p>My question:</p>

<p>For example, my text file is call 'feed.txt'. and for inside, it likes that:</p>

<pre><code>2 # two means 'there are two matrix in this file'

3 # three means 'the below one is a 3*3 matrix'

1 8 6

3 5 7

4 9 2

4 # four means 'the below one is a 4*4 matrix'

16 3 2 13

5 10 11 8

9 6 7 12

4 15 14 1
</code></pre>

<p>There are two matrix in side this file. <code>[[1,8,6],[3,5,7],[4,9,2]]</code> and <code>[[16,3,2,13],[5,10,11,8],[9,6,7,12],[4,15,14,1]]</code>.</p>

<p>I want to know how can I use these two matrix in Python as a list which like </p>

<pre><code>list_=[[1, 8, 6], [3, 5, 7], [4, 9, 2]]
</code></pre>

<p>and then I can get <code>sam(list_[0])=15</code>.</p>

<p>also. there are three rows in </p>

<pre><code>list_=[[1, 8, 6], [3, 5, 7], [4, 9, 2]]
</code></pre>

<p>and I want to do the sum of each row. So I did</p>

<p>list_=[[1, 8, 6], [3, 5, 7], [4, 9, 2]]</p>

<p>for i in range(len(list_)): </p>

<pre><code>sum_=sum(list_[i])

print(sum_)
</code></pre>

<p>but I cannot get three numbers, I only get one number, why ?</p>
