Documentation

Type defined in library builtins

TypeError

Python raises a type error when an operation is applied to a value of inappropriate type.

Note that the text of the error message depends on the implementation. Different versions of Python and different checking tools will give slightly different messages.

Code
"Age: " + 18
error
TypeError: can only concatenate str (not "int") to str
Code
abs("Hello")
error
TypeError: bad operand type for abs(): 'str'
Code
rectangle(100, 20, "red")
error
TypeError: Invalid type for parameter `color`: expected `Color`, got `str`

Logo of PyTamaro

PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI

Privacy PolicyPlatform Version a9143b0 (Sun, 14 Dec 2025 12:09:46 GMT)