Paul Moore <[email protected]> added the comment:
Works fine for me:
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a = ['1','2','3']
>>> b = [1,2,3]
>>> c = zip(a,b)
>>> print(dict(list(c)))
{'1': 1, '2': 2, '3': 3}
>>> print(dict(list(zip(a,b))))
{'1': 1, '2': 2, '3': 3}
>>> d = zip(b,a)
>>> print(dict(list(d)))
{1: '1', 2: '2', 3: '3'}
Are you sure you didn't try to use c twice? If you do, it will start up from
where it left off (at the end) and so generate no further values:
>>> print(dict(list(c)))
{}
You need to remember that c is an iterator, and this is how iterators work. (If
you're coming from Python 2, this is new behaviour in Python 3).
----------
resolution: -> not a bug
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37164>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com