In Python 3, you can also emulate the Python 2 behavior of zip() by wrapping the returned iterator in a call to list(). The first iteration is truncated at C, and the second one results in a StopIteration exception. ![]() Here, your call to zip() returns an iterator. ![]() ![]() # Python 3 > zipped = zip ( range ( 3 ), 'ABCD' ) > zipped # Hold an iterator > type ( zipped ) > list ( zipped ) > zipped = zip () # Create an empty iterator > zipped > next ( zipped ) Traceback (most recent call last):įile "", line 1, in next ( zipped ) StopIteration
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |