Y
Hacker News
new
|
ask
|
show
|
jobs
by
nine_k
3183 days ago
It does if you specify a sequence of list as the first argument, and an empty list as an initial value.
1 comments
vostok
3183 days ago
This is because the start argument defaults to 0. It doesn't make sense to add a list and 0.
The same thing does not work for a sequence of strings and an empty string.
sum(["abc","def"], "")
Throws TypeError: sum() can't sum strings [use ''.join(seq) instead]
link
The same thing does not work for a sequence of strings and an empty string.
Throws TypeError: sum() can't sum strings [use ''.join(seq) instead]