TypeError operand 🐍 Python

TypeError: unsupported operand type(s) for +: 'int' and 'str'

An operator was used between two incompatible types, such as adding a number to a string.

Seen on: Python

Meaning

Python doesn’t convert types implicitly. Values read from input(), files, JSON or environment variables are strings even when they look like numbers.

Common causes

  • input() / env var / CSV value used as a number
  • None in arithmetic (NoneType)
  • Mixing lists and numbers

⚡ Quick fix

  1. Convert explicitly: int(x), float(x), str(x)
  2. Use f-strings for text: f"{count} items"
  3. Check for None before arithmetic

Detailed fix by platform

Python

  1. total = int(qty) * float(price)

How to diagnose

  1. Types — Which two types are named?
  2. Source — Where does each value come from?

🧠 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.