Multi-variable for loop with a tuple and a array
<pre><code>Cols = [(10,11),(8,9),(6,7),(4,5),(2,3),(0,1)]
Index = [1,2,3,4,5,6]
Temp = ['RT','85C','125C','175C','220C','260C']


for i,c,t in Index, Cols, Temp:
    print(i,c,t)
</code></pre>

<p>I wish to have i as a tuple, c as an integer and t as a string. When i try the above I keep getting a: </p>

<p><strong>ValueError: too many values to unpack (expected 3)</strong></p>

<p>So I tried following as suggested by other solutions:</p>

<pre><code>x = [[(10,11),(8,9),(6,7),(4,5),(2,3),(0,1)], [1,2,3,4,5,6], ['RT','85C','125C','175C','220C','260C']]

for c,i,t in x:
    print(i,c,t)
</code></pre>

<p>But got the same error as well. Here is what I wish to obtain is:</p>

<pre><code>First loop:
i = 1
c = (10,11)
t = 'RT'

Second loop:
i = 2
c = (8,9)
t = '85C'
.
.
.
.
</code></pre>

<p>You need to use the <a href="https://docs.python.org/3/library/functions.html#zip" rel="nofollow"><code>zip</code></a> function to iterate through your lists element-wise</p>

<pre><code>for i,c,t in zip(Index, Cols, Temp):
    print(i,c,t)
</code></pre>

<p>Output</p>

<pre><code>1 (10, 11) RT
2 (8, 9) 85C
3 (6, 7) 125C
4 (4, 5) 175C
5 (2, 3) 220C
6 (0, 1) 260C
</code></pre>

python python-3.x jupyter-notebook