Python: trying to get three elements of a list with slice over a iterator
<p>I'm new to python.</p>

<p>I'm trying to create another list from a big one just with 3 elements of that list at a time.</p>

<p>I'm trying this:</p>

<pre><code>my_list = ['test1,test2,test3','test4,test5,test6','test7,test8,test9','test10,test11,test12']
new_three = []
for i in my_list:    
    item = my_list[int(i):3]
    new_three.append(item)

    # here I'll write a file with these 3 elements. Next iteration I will write the next three ones, and so on...
</code></pre>

<p>I'm getting this error:</p>

<pre><code>item = my_list[int(i):3]
ValueError: invalid literal for int() with base 10: 'test1,test2,test3'
</code></pre>

<p>I also tried:</p>

<pre><code>from itertools import islice
for i in my_list:
    new_three.append(islice(my_list,int(i),3))
</code></pre>

<p>Got the same error. I cannot figure out what I'm doing wrong.</p>

<p>EDIT:</p>

<p>After many tries with help here, I could make it. </p>

<pre><code>listrange = []
for i in range(len(li)/3 + 1):
    item = li[i*3:(i*3)+3]
    listrange.append(item)
</code></pre>