Append first item into array list when still have space in array list
<p>let's say I need to store 2 elements into a list.</p>

<p>I have 5 items: apple, orange, lemon, papaya, banana</p>

<p>These items i save in a text file, hence there're 5 lines.</p>

<p>I connect the file and start read line by line. Everytime I read a line I append one item in array. Each time the array will fill up by 2 items and when it's full I will empty it and store the next 2 items.</p>

<p>What should I do when it reach the last item? I still have one extra place and I plan to store the 1st item again?</p>

<p>Example:</p>

<pre><code>1st time store
apple, orange, 

2nd time store
lemon, papaya,

3rd time store
banana, apple

4th time store
orange, lemon
</code></pre>

<p>loop........</p>

<p>My current code is unable do so:</p>

<pre><code>def function():
    fo = open("1.txt", "r")
    print "Name of the file: ", fo.name 
    sent_count=0
    ele = []
    while True:
        lines = fo.readlines()   
        for line in lines:
            sent_count+=1
            if(sent_count%4!=0):
                ele.append(lines[sent_count-1])
            if(sent_count%4==0):
                ele.append(lines[sent_count-1])
                for i in ele:
                    print i
                ele = []
                print(sent_count)
                time.sleep(1) 
</code></pre>