Home › Errors › TypeError

Python TypeError: unsupported operation between types

Exception: TypeErrorCategory: type mismatchRaised at: runtime

What this error means

A TypeError says the operation you requested is not defined for the type of value you gave it — regardless of the value itself. 'Score: ' + 90 fails not because 90 is wrong but because str + int has no meaning in Python; the language refuses to guess whether you wanted 'Score: 90' or arithmetic.

This is the deliberate opposite of JavaScript's silent coercion. Python's philosophy: better a loud crash at the exact line than a quietly wrong value that travels through your program. Because TypeErrors cover every kind of type mismatch, the message wording varies a lot — but each variant names the offending types, and that is the clue that matters.

A real example

score = 90
print("Your score: " + score)
Traceback (most recent call last):
  File "app.py", line 2, in <module>
    print("Your score: " + score)
          ~~~~~~~~~~~~~~~^~~~~~~
TypeError: can only concatenate str (not "int") to str

The fix is stating your intent: print(f"Your score: {score}") converts for display, while int(text) + score would convert for arithmetic.

The message decoder

Five wordings account for most Python TypeErrors — each points at a different mistake:

How to debug it

  1. Read the type names in the message — they identify both operands, which is half the diagnosis.
  2. Find which operand has the "surprising" type, then trace where that value was produced. input() returning str is the classic upstream source.
  3. Decide the intent before converting: display (f-string), arithmetic (int()/float()), or a genuinely wrong value that should never have arrived.
  4. Fix at the source, not the crash site — converting at the point of creation prevents the same TypeError three lines later.
  5. Use print(type(x), repr(x)) when unsure; repr distinguishes 5 from '5' instantly.

Fix it interactively

Each of these free problems is a real TypeError variant, runnable and fixable in your browser:

Practice more Python bugs →
🇮🇳 Hindi में समझें

आपने दो ऐसी चीज़ें mila दीं जिनका आपस में कोई operation नहीं बनता — जैसे "Score: " + 90 (text + number)। Python guess नहीं करता, रुक जाता है। सबसे आसान fix: f-string — f"Score: {score}" — यह conversion खुद कर देता है। Message में दोनों types के नाम लिखे होते हैं, वही असली clue है।

पूरी Hindi explanation पढ़ें →

Related errors

Full catalogue with AttributeError, ImportError and more: Python errors guide.