fuckingpython.lol

Python errors › TypeError

TypeError: can only concatenate str (not "int") to str

Updated

The Python error 'can only concatenate str (not "int") to str' means + joined text and a number. Python never converts the number for you. Three ways to fix it.

What you see

main.py
age = 36
print("Age: " + age)
Python 3.15 prints
Traceback (most recent call last):
  File "/home/me/project/main.py", line 2, in <module>
    print("Age: " + age)
          ~~~~~~~~^~~~~
TypeError: can only concatenate str (not "int") to str

What it means

+ between two strings joins them. Between a string and a number it is an error: Python does not turn 36 into "36" on its own, because it cannot know whether you wanted text or arithmetic.

The type in brackets is the one on the right of the +. With a list it says (not "list"), with None it says (not "NoneType").

Why it happens

  • Building a message with + from text and numbers, as in the example.
  • A number from a calculation joined to a label: "Total: " + price * qty.
  • A value you expected to be text that is a number, from JSON or a database.

How to fix it

An f-string is the usual way. It converts each value for you:

print(f"Age: {age}")

Or convert explicitly with str():

print("Age: " + str(age))

print() with commas also works, and puts a space between items: print("Age:", age).

How each Python version words it

PythonPrints
3.9–3.15TypeError: can only concatenate str (not "int") to str

Run on CPython 3.9.6, 3.10.22, 3.11.17, 3.12.15, 3.13.17, 3.14.9 and 3.15.1, on October 25, 2026.

The wording is the same in every version here. With the number on the left, 36 + " years", the message is different: "unsupported operand type(s) for +: 'int' and 'str'".

Questions

Why does input() cause the opposite problem?

input() always returns a string, so input() + 1 fails with this same message, and "2" + "2" is "22". Convert first: int(input()).

How do I join a list of numbers into one string?

", ".join(str(n) for n in numbers). join() itself only accepts strings, which is why the conversion is inside it.

Sources

Read on October 25, 2026.