PlainError

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

Last checked 2026-11-09 · 3 fixes · reviewed answer

TL;DRYour Python code tried to join a piece of text (string) directly with a number (int) using the + sign, which Python does not allow.

Most likely cause: Using + to combine a string variable with an integer variable without first converting the integer to a string

Try first: Locate the exact line

Likely causes

  1. Using + to combine a string variable with an integer variable without first converting the integer to a stringmost likely
  2. A variable expected to hold text actually holds a number due to earlier code logicpossible
  3. Mixing data types from user input, file data, or API responses without explicit conversionless likely

How to fix it

Safest first: SafeChanges settingsDangerous
  1. Locate the exact lineSafe

    Run the script again and note the line number shown in the error traceback.

  2. Inspect the variables on that lineSafe

    Add print statements before the line to show the type and value of each variable involved in the concatenation.

  3. Convert the number to textChanges settings

    Change the code to use str(your_number) or an f-string like f"text {your_number}" instead of direct + concatenation.

If that didn't fix it

Add type checks with isinstance() around the concatenation to see which variable has the wrong type.

When to see a technician

If this error occurs inside a larger application you did not write, ask the original developer to review the data types being passed.

Quick answers

What does TypeError: can only concatenate str (not "int") to str mean?
Your Python code tried to join a piece of text (string) directly with a number (int) using the + sign, which Python does not allow.
What causes TypeError: can only concatenate str (not "int") to str?
Using + to combine a string variable with an integer variable without first converting the integer to a string. (most likely) A variable expected to hold text actually holds a number due to earlier code logic. (possible) Mixing data types from user input, file data, or API responses without explicit conversion. (less likely)
How do I fix TypeError: can only concatenate str (not "int") to str?
Try these in order, safest first: 1. Locate the exact line. 2. Inspect the variables on that line. 3. Convert the number to text.
What if that didn't fix it?
Add type checks with isinstance() around the concatenation to see which variable has the wrong type.
When should I see a technician?
If this error occurs inside a larger application you did not write, ask the original developer to review the data types being passed.
Did this fix it? Report a problem

Related errors

All Coding errors →