Looping zipped list in python
<p>I was toying around with the zip() function in python and discovered a problem while using the for loop.
Here is my code:</p>

<pre><code>list1 = ['monday', 'tuesday', 'wednesday', 'thursday']
list2 = [1, 2, 3, 4]

zipped_list = zip(list1, list2)

print(*zipped_list)  # unpacked zipped list

for a, b in zipped_list:   # for this to work comment the print(*zipped_list) statement
    print(a, b)
</code></pre>

<p>The output for this code is:</p>

<pre><code>('monday', 1) ('tuesday', 2) ('wednesday', 3) ('thursday', 4)

Process finished with exit code 0
</code></pre>

<p>Now if I remove the print(*zipped_list) statement then the for loop gets executed correctly:</p>

<pre><code>monday 1

tuesday 2

wednesday 3

thursday 4

Process finished with exit code 0
</code></pre>

<p>Why is this happening ?</p>