File loop.. How do you make a list out of file
<p>For example if we have a file that looks like this:</p>

<pre><code>A
1,2,3,4
2,3,4,1
2,4,1,3

B
3,2,1,4
2,1,4,3
4,3,1,2
</code></pre>

<p>And we want to make this file and we want to open it so that it looks like:</p>

<pre><code>['A'
[1,2,3,4], 
[2,3,4,1], 
[2,4,1,3],
'B',
[3,2,1,4],
[2,1,4,3],
[4,3,1,2]]
</code></pre>

<p>And then we want to call the function using just 'A' or 'B'.. </p>

<p>How can we do so?
thanks</p>

<p>I have tried this.. sorry</p>

<pre><code>def list_of_list(file):
    counter = 0
    big_list = []
    small_list = []
    for next_item in file:
        #Set a variable for each element to get rid of the spaces but using strip() function
        next_item = next_item.strip()
        if next_item == "":
            counter+=1
        if next_item == "A" and next_item == counter:
            big_list.append(small_list)
            small_list = []
        else:
            small_list.append(next_item)
    if ballot:
        big_list.append(small_list)
    print (big_list)
</code></pre>

<p>And i am trying to call a function in a program i made.. where i need a 4--element tuple. 
I hope that makes things clearer?</p>

<p>The problem with what i tried is that it keeps putting 'A' and 'B' in a sperate list, and i wanna be able to use 'A' and 'B' to use the lists they hold.. </p>

<pre><code>like if i input 'A' it should give me:
[1,2,3,4], 
    [2,3,4,1], 
    [2,4,1,3]
and the same with 'B',
[3,2,1,4],
    [2,1,4,3],
    [4,3,1,2]
</code></pre>

<p>So yeah.. 
also, is there a way to partially loop through a file.. 
meaning, is there a way where i can run a loop only through 'A' and only through 'B' using some sort of infinite loop?</p>
