[issue7176] sum() doesn't work for lists.

Mark Dickinson report at bugs.python.org
Tue Oct 20 15:53:23 CEST 2009

Mark Dickinson <dickinsm at gmail.com> added the comment:

To sum lists, you need to supply a second argument to sum:

>>> sum([[1, 2], ['x', 'y']], [])
[1, 2, 'x', 'y']

The default value of the second argument is 0, which is why you're seeing 
the TypeError.

nosy: +mark.dickinson
resolution:  -> invalid
status: open -> closed

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list