TypeError: unsupported operand type(s) for +: 'int' and 'str'
Python 3
TypeError: unsupported operand type(s) for +: 'int' and 'str' (or a similar type combination).
What it means (root cause)
An operation combines incompatible types — most often concatenating a string with a non-string (f-strings or str() fix it), or calling a method on a None that resulted from a failed parse.
The symptom developers actually see: TypeError: unsupported operand type(s) for +: 'int' and 'str' (or a similar type combination).
Step-by-step fix
Concrete, ordered steps from the dataset. Apply them in order; each line is a verified action, not generic advice.
- 1Make types explicit: str(x) + y, or use an f-string f'{x}{y}' for concatenation.
- 2Check the value is not None before calling a method on it (a failed API parse often returns None).
- 3For numeric math, cast inputs with int()/float() after validating they parse.
Where this error appears
Languages, frameworks, and runtimes where this error is observed (from the 2026 DevFixPro error dataset, retrieved 2026-08-29):
Python 3. Unlike JS, Python does not implicitly coerce types in arithmetic or string concatenation.
How to prevent it & common questions
Practical prevention plus the questions developers ask most about this error.
What does "TypeError: unsupported operand type(s) for +: 'int' and 'str'" mean?
An operation combines incompatible types — most often concatenating a string with a non-string (f-strings or str() fix it), or calling a method on a None that resulted from a failed parse.
Which environments are affected by TypeError: unsupported operand type(s) for +: 'int' and 'str'?
Python 3
How do I fix TypeError: unsupported operand type(s) for +: 'int' and 'str'?
Make types explicit: str(x) + y, or use an f-string f'{x}{y}' for concatenation. Check the value is not None before calling a method on it (a failed API parse often returns None). For numeric math, cast inputs with int()/float() after validating they parse.
How do I prevent TypeError: unsupported operand type(s) for +: 'int' and 'str'?
Parse and validate types at the boundary; use f-strings for concatenation so the conversion is explicit.
Why can't I add a string and an int?
Python does not auto-coerce. Convert explicitly: str(n) + s, or f'{n}{s}'. The TypeError prevents silent, wrong results.
Where does the None come from?
Often a failed int()/float() or a missing dict key returned None; guard the parse before you operate on the value.
Related DevFixPro tools
Real, browser-only utilities on DevFixPro that help while you work through this issue. These are navigation aids, not a substitute for the fix above.
Sources & attribution
- Error records aggregated from Google Search Console query gaps (2026-05-21~2026-08-18) for devfixpro.com, plus official framework docs (MDN, Node.js docs, Python docs, Go.dev, Rust book, Oracle Java docs, Docker docs, npm docs). Source dataset retrieved 2026-08-29. License: CC BY 4.0 — attribute DevFixPro (devfixpro.com).
- Official reference: https://docs.python.org/3/library/exceptions.html#TypeError
- All cause, environment, fix and prevention text on this page is taken verbatim from the DevFixPro 2026 error dataset. DevFixPro does not invent root causes or fixes.
How this TypeError: unsupported operand type(s) for +: 'int' and 'str' page is built
Each error page is generated from a single record in the DevFixPro 2026 error dataset. The meaning, root cause, environments, fix steps, prevention, and official references are copied verbatim from that dataset and its official-doc sources; related-error links are computed from the error's category and explicit peer list. No root cause or fix is invented. The retrieval date for this dataset is 2026-08-29.