Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
string concatenation via `sum` #1632
Comments
|
This is the repository and issue tracker for the https://www.python.org website. If you're looking to file an issue with CPython itself, please go to https://bugs.python.org |
|
Hey dear |
|
But if it still not works then I think that the sum () function can only add integers and floats |
|
It's because Then Python basically tries to do: result = 0
for item in ('a', 'b', 'c'):
result += itemYou can create a bug report at bugs.python.org and ask if it's possible to improve error message, but I'd expect it's going to be rejected since it's a rare usage. |
I'm not sure whether this is a bug or a feature request, but it seems as though the following should produce the same result:
In [1]: 'a' + 'b' + 'c'
Out[1]: 'abc'
In [2]: sum(('a', 'b', 'c'))
TypeError Traceback (most recent call last)
in
----> 1 sum(('a', 'b', 'c'))
TypeError: unsupported operand type(s) for +: 'int' and 'str'
The error message is confusing (there is no integer).
The text was updated successfully, but these errors were encountered: