Skip to main content
2 of 3
deleted 4 characters in body
Anand S Kumar
  • 91.4k
  • 18
  • 196
  • 179

zip() function in Python 3 returns an iterator. That is the reason why when you print test1 you get - <zip object at 0x1007a06c8> . From documentation -

Make an iterator that aggregates elements from each of the iterables.

But once you do - list(test1) - you have exhausted the iterator. So after that anytime you do list(test1) would only result in empty list.

In case of test2 , you have already created the list once, test2 is a list, and hence it will always be that list.

Anand S Kumar
  • 91.4k
  • 18
  • 196
  • 179