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:
can only concatenate str (not "int") to str— mixing text and numbers with+. Use an f-string or convert one side.'int' object is not callable— parentheses after a non-function; usually a variable that shadowed a function (sum = sum(nums)).'int' object is not iterable— a for-loop over a number;for i in 5:should befor i in range(5):.'tuple' object does not support item assignment— writing into an immutable container; you need a list, or a new tuple.missing 1 required positional argument— the call supplied fewer arguments than thedefline requires; the message names the missing one.
How to debug it
- Read the type names in the message — they identify both operands, which is half the diagnosis.
- Find which operand has the "surprising" type, then trace where that value was produced.
input()returningstris the classic upstream source. - Decide the intent before converting: display (f-string), arithmetic (
int()/float()), or a genuinely wrong value that should never have arrived. - Fix at the source, not the crash site — converting at the point of creation prevents the same TypeError three lines later.
- Use
print(type(x), repr(x))when unsure;reprdistinguishes5from'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 है।
Related errors
- ValueError — right type, wrong value — int('abc') is a ValueError, int + str a TypeError.
- NameError — the name itself is missing, before types even enter the picture.
Full catalogue with AttributeError, ImportError and more: Python errors guide.