Learn
Python TypeError: what it means and how to fix it
Last updated: August 22, 2026
Read Python TypeError messages for bad operands, missing arguments, and None. Fix a small example in the online compiler without installing Python.
See TypeError, then convert the valueThe operation and the value disagree
TypeError means Python understood the names and still could not do what you asked. The message usually names the operation and the types: can only concatenate str (not "int") to str.
That sentence is enough. Convert a value, or stop mixing types. Do not catch TypeError to paper over a bad model. The next input will throw again.
In Code Arena, print type(value) and the value on the line before the crash. Many TypeErrors disappear once you see '12' instead of 12.
The common families
String-plus-number is the beginner classic. Homework snippets often start as quoted numbers by accident. age = "12" then age + 1 fails. Use age = 12, or int(age) if the text really came from input-like data.
NoneType is not iterable or not callable usually means a function returned None — a missing return — and you used that result as a list or a function.
takes X positional arguments but Y were given is a call-shape bug. Count the values against the def line. Extra commas and forgotten self-style arguments show up here even in simple scripts.
- Print type(x) before the failing line
- Convert with int() or str() only when that is really what you want
- Check return — did the function forget to return?
- Count arguments against the def line
Fix the starter snippet
age + 1 fails because age is a string. Change it to age = 12, or print(int(age) + 1). Both work; the first is clearer if age is meant to be a number all along.
When Output prints 13, you have finished the TypeError. Then try age + " years" to see the other direction — now you need a string.
That pair of runs is the whole type-conversion lesson for early courses.
FAQ
- What is a TypeError in Python?
- An operation received a value of the wrong type — adding a str to an int, calling something that is not callable, or passing the wrong number of arguments.
- How do I see the real types?
- Print type(value) and the value on the line before the crash. Many TypeErrors disappear once you see '12' instead of 12.
- Can I practice TypeError without installing Python?
- Yes. Use Code Arena’s Python editor. Run the snippet, read Output, change one value, and Run again.