zip list, variables

flebber flebber.crue at gmail.com
Wed Nov 20 05:06:29 EST 2013


If 

c = map(sum, zip([1, 2, 3], [4, 5, 6]))

c
Out[7]: [5, 7, 9]

why then can't I do this? 

a = ([1, 2], [3, 4])

b = ([5, 6], [7, 8])

c = map(sum, zip(a, b))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-cc046c85514b> in <module>()
----> 1 c = map(sum, zip(a, b))

TypeError: unsupported operand type(s) for +: 'int' and 'list'

How can I do this legally?

Sayth



More information about the Python-list mailing list