0

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 zippeddefinition (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 forloop the first time, it lost its value. I would like to understand the logic behind all this.

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153

0 Answers0