TypeError: can only concatenate str (not "int") to str (tested fix)
TypeError: can only concatenate str (not "int") to str means you used + between a string and a number. We reproduced it with int, float, None and list in Python 3.13, plus the reversed-order message and a related silent bug.
1. + does not convert types
In Python, + between a string and a number is an error, not an automatic conversion. The message names the type you tried to add, and it changes with the order of the operands:
age = 31
for expr in ['"age: " + age', '"n=" + 2.5', '"x" + None', '"tags: " + ["a"]', '[1] + "a"', '5 + "5"']:
try:
eval(expr); print(f"{expr:18} OK")
except TypeError as e:
print(f"{expr:18} TypeError: {e}")
Output:
"age: " + age TypeError: can only concatenate str (not "int") to str
"n=" + 2.5 TypeError: can only concatenate str (not "float") to str
"x" + None TypeError: can only concatenate str (not "NoneType") to str
"tags: " + ["a"] TypeError: can only concatenate str (not "list") to str
[1] + "a" TypeError: can only concatenate list (not "str") to list
5 + "5" TypeError: unsupported operand type(s) for +: 'int' and 'str'
With the string on the left you get can only concatenate str (not "int") to str. With the number on the left, the message becomes unsupported operand type(s) for +: 'int' and 'str'. Both are the same mistake. (not "NoneType") means the value is None, usually from a function that returned nothing. See our NoneType guide for where that comes from.
2. The fix: str(), an f-string, or print with commas
age, price = 31, 2.5
print("age: " + str(age))
print(f"age: {age}, price: {price:.2f}")
print("age:", age) # print() converts and adds a space
print("-".join(str(n) for n in [1, 2, 3]))
Output:
age: 31
age: 31, price: 2.50
age: 31
1-2-3
An f-string is usually the clearest. It converts automatically and can format numbers. print() with commas converts each argument and puts spaces between them. To join a list of numbers, convert each item first, since "-".join([1, 2, 3]) also raises TypeError.
3. The opposite case: numbers that are really strings
input(), CSV fields and query parameters are always strings. Adding two strings concatenates them instead of raising an error, so the bug is silent:
qty = "3" # input() and file/CSV fields are always str
print(qty + "1") # concatenation, not addition
print(int(qty) + 1)
Output:
31
4
Convert with int() or float() as soon as you read the value.
Frequently asked questions
How do I fix can only concatenate str (not "int") to str?
Convert the number: "age: " + str(age), or use an f-string: f"age: {age}".
Why does 5 + "5" give a different error?
With the int on the left, Python reports unsupported operand type(s) for +: 'int' and 'str'. It is the same mistake.
Why does "3" + "1" give "31"?
Both are strings, so + concatenates. Convert input() and CSV values with int() or float() first.
Written with AI assistance. Measured on 2026-10-22 on Debian with Python 3.13.5: str + int, float, None and list, list + str, int + str, the str()/f-string/print/join fixes, and adding two numeric strings. Every block was run verbatim and its output pasted unedited. PlainHeaders is our extension; Python is free.