Consider this for
loop:
zipped = zip([1,2,3], [4,5,6])
for a, b in zipped:
print(a, b)
This, as expected, returns:
1 4
2 5
3 6
However, if I rerun the exact same code again but skipping the zipped
definition (as it was already defined above), it returns nothing:
for a, b in zipped:
print(a, b)
zipped is still the zip
element that I created above, but it seems as if, after executing the for
loop the first time, it lost its value. I would like to understand the logic behind all this.