Why does Python not perform type conversion when concatenating strings?

Viewed 7209

In Python, the following code produces an error:

a = 'abc'
b = 1
print(a + b)

(The error is "TypeError: cannot concatenate 'str' and 'int' objects").

Why does the Python interpreter not automatically try using the str() function when it encounters concatenation of these types?

8 Answers
Related