Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
nine_k
· 5y ago · 0 comments
What. Python's `sum()` works on anything that defines `__add__`, which can be numbers, strings, lists, or your own custom classes.
sum([[1, 2], [3, 4]], []) == [1, 2, 3, 4]
Comments
[–]
nitroll
5y ago
Actually it seems sum is special cased to fail for strings, but otherwise you are correct