May-03-2019, 02:32 PM
(This post was last modified: May-03-2019, 02:35 PM by Gribouillis.)
In the for statement
for item in FOO: do_something()Python expects FOO to be an iterable. By default, an iterable can be traversed once, then it is exhausted. It's like a pack of cookies, you can eat then only once until the pack is empty. This is what happens with the zip object. If you want an iterable that can be traversed more than once, use a list
loft = list(zip(ll, ld))The difference is that the list instance keeps pointers to all the items in memory while the zip object instance does not. Python's default behavior saves memory in many cases.