TypeError concat 🐍 Python

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

You joined a string and a non-string with +.

Seen on: Python

Meaning

String concatenation requires both sides to be str. Convert the number, or better, use an f-string.

Common causes

  • "Total: " + total where total is an int
  • Concatenating None or a list
  • Building paths with + instead of os.path/pathlib

⚡ Quick fix

  1. Use f-strings: f"Total: {total}"
  2. Wrap with str()
  3. Use pathlib for paths

Detailed fix by platform

Python

  1. print(f"Processed {count} rows in {elapsed:.2f}s")

How to diagnose

  1. Operands — Which value is not a string?
  2. Intent — Formatting text or adding numbers?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.