how to loop over multiple lists in python
<p>Below, set1, set2, set3 are lists with len(setn) =len(index). I want to loop over each of these lists (setn) as follows, </p>

<pre><code>index = range(10)
set1 = range(10,20)
set2 = range(30,40)
set3 = range(40,50)
listset = [set1, set2, set3]
for i in listset:
  for k, j in zip(index, i):
     print k, j

Result:
0 s
1 e
2 t
3 1
0 s
1 e
2 t
3 2
0 s
1 e
2 t
3 3
</code></pre>

<p>How can I get a result that prints the each element of "index, set1" (as given below),followed by "index, set2", followed by "index, set3". </p>

<pre><code>0 10
1 11
2 12
3 13
4 14
5 15
6 16
7 17
8 18
9 19
and so on...
</code></pre>

<p>You can concatenate set1, 2 and 3 together, then use itertools.cycle(index) and zip the resulting two things together:
    <code>zip(itertools.cycle(index), set1 + set2 + set3)</code></p>

python list loops