Message344730
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). |
|
Date |
User |
Action |
Args |
2019-06-05 15:00:03 | paul.moore | set | recipients:
+ paul.moore, tim.golden, zach.ware, steve.dower, Dane Howard |
2019-06-05 15:00:03 | paul.moore | set | messageid: <1559746803.65.0.153127331257.issue37164@roundup.psfhosted.org> |
2019-06-05 15:00:03 | paul.moore | link | issue37164 messages |
2019-06-05 15:00:03 | paul.moore | create | |
|