ShareYourGroupShareYourGroupError Explainer

Python TypeError: can only concatenate str to str

A plain-words explanation of this Python message: what it means, the usual causes, and the steps that fix it.

The messageTypeError: can only concatenate str (not "int") to str

Make the error yourself

Run with Python 3.14.10. This is the smallest example we could find that shows it.

Python program (main.py)

age = 30
print("Age: " + age)

Output (the real message)

Traceback (most recent call last):
  File "main.py", line 2, in <module>
    print("Age: " + age)
          ~~~~~~~~^~~~~
TypeError: can only concatenate str (not "int") to str

Why it happens

The + sign joins two strings, or adds two numbers, but it will not mix them. Python will not guess whether "Age: " + 30 should become "Age: 30" or the other way, so it stops. The message tells you the type it found, here int, where it wanted a string.

How to fix it

  1. Turn the number into text with str(age).
  2. Better, use an f-string: f"Age: {age}". It converts for you and is easier to read.
  3. If the value came from input(), remember it is text. Use int(...) when you need to calculate with it.

The corrected version

Python program (main.py)

age = 30
print("Age: " + str(age))
print(f"Age: {age}")

Output (the corrected version)

Age: 30
Age: 30

How to avoid it

Prefer f-strings for printing. They also let you format numbers, for example f"{price:.2f}" for two decimal places.

Questions

What about the reverse: unsupported operand type(s) for +: 'int' and 'str'?

That is the same mistake with the order swapped: a number on the left, text on the right. The fix is the same.

This is an independent guide. It is not connected with Python, Microsoft, Google, GitHub or the Git project. Product names belong to their owners. Examples were run on 13 November 2026 in a practice folder or a blank workbook; your version may word a message slightly differently.