TypeError: <lambda>() takes exactly 1 argument (3)

Angesichts dieser code:

sumThree = lambda (x, y, z): (x[0]+ y[0] + z[0], x[1] + y[1] + z[1])
print 'sumThree((1, 2), (3, 4), (5, 6)) = {0}'.format(sumThree((1, 2), (3, 4), (5, 6)))

Bekomme ich:

TypeError                                 Traceback (most recent call last)
<ipython-input-43-7f1b9571e230> in <module>()
     16 # second position summed. E.g. (1, 2), (3, 4), (5, 6) => (1 + 3 + 5, 2 + 4 + 6) => (9, 12)
     17 sumThree = lambda (x0, x1, x2): (x[0]+ y[0] + z[0], x[1] + y[1] + z[1])
---> 18 print 'sumThree((1, 2), (3, 4), (5, 6)) = {0}'.format(sumThree((1, 2), (3, 4), (5, 6)))

TypeError: <lambda>() takes exactly 1 argument (3 given)

Und die Frage ist natürlich, warum?

InformationsquelleAutor IttayD | 2015-07-16

Schreibe einen Kommentar