Skip to content
Python ExceptionsError
TypeError

TypeError

An operation or function was applied to an object of an inappropriate type.

python

What causes this error

You performed an operation on incompatible types, such as adding a string to an integer, calling a non-callable object, passing wrong argument types, or using an object that does not support the required protocol (iteration, indexing, etc.).

How to fix it

Check the types of your variables with type(). Convert types explicitly: str(), int(), float(), list(). Use isinstance() for type checking. Read the error message carefully; it usually tells you exactly which types are incompatible.

Example

"hello" + 5  # TypeError: can only concatenate str to str
Official Documentation

Related Error Codes