KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am seeing a strange behavior when working with the zip() function. When I perform the following operation len(list(z)) where z is a zip object, the result is 0 (which seems wrong to me), and the action seems to clear out the zip object. Can someone please help me understand what is going on. # python3 Python 3.2.3 (default, Sep 30 2012, 16:41:36) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> w = [11, 22, 33, 44, 55, 66] >>> x = [1, 2, 3, 4] >>> y = ['a', 'b', 'c'] >>> z = zip(x, y, w) >>> z <zip object at 0x7f854f613cb0> >>> list(z) [(1, 'a', 11), (2, 'b', 22), (3, 'c', 33)] >>> len(list(z)) 0 >>> list(z) [] >>> z <zip object at 0x7f854f613cb0> >>> Thank you, Ahmed.
Tags (comma-separated)
Save Edits
Cancel