T
tkpmep
I using Python 3.2 and have a dictionary
whose values are lists I would like to zip into a list of tuples. If I explicitly write:
I get exactly what I want. On the other hand, I have tried
[(0,), (1,), (2,)]
[([1, 2],), ([1, 2, 3],), ([1, 2, 3, 4],)]
[([1, 2],), ([1, 2, 3],), ([1, 2, 3, 4],)]
Traceback (most recent call last):
File "<pyshell#48>", line 1, in <module>
list(zip(*d))
TypeError: zip argument #1 must support iteration
and nothing quite works. What am I doing wrong?
Sincerely
Thomas Philips
d = {0:[1,2], 1:[1,2,3], 2:[1,2,3,4]}
whose values are lists I would like to zip into a list of tuples. If I explicitly write:
[(1, 1, 1), (2, 2, 2)]list(zip([1,2], [1,2,3], [1,2,3,4])
I get exactly what I want. On the other hand, I have tried
[(0,), (1,), (2,)]
[([1, 2],), ([1, 2, 3],), ([1, 2, 3, 4],)]
list(zip(d for i in d))
[([1, 2],), ([1, 2, 3],), ([1, 2, 3, 4],)]
Traceback (most recent call last):
File "<pyshell#48>", line 1, in <module>
list(zip(*d))
TypeError: zip argument #1 must support iteration
and nothing quite works. What am I doing wrong?
Sincerely
Thomas Philips