ShareYourGroupShareYourGroupPython

TypeError: wrong kind of value

A TypeError means you asked Python to do something with a value of the wrong kind. Adding a number to text, giving a function too many arguments, or putting brackets after something that is not a function all raise it. The message usually names the types involved, which points straight at the fix.

Cause 1: text plus a number

age = 14
print("Age: " + age)

What Python says

Traceback (most recent call last):
  File "example.py", line 2, in <module>
    print("Age: " + age)
          ~~~~~~~~^~~~~
TypeError: can only concatenate str (not "int") to str

Python will not guess whether you want to add numbers or join text. Tell it. Convert the number with str, or let an f-string or a comma in print do the work.

age = 14
print("Age: " + str(age))
print(f"Age: {age}")
print("Age:", age)

Output

Age: 14
Age: 14
Age: 14

The mirror image happens with input, which always returns text.

typed = "14"
print(typed + 1)

What Python says

Traceback (most recent call last):
  File "example.py", line 2, in <module>
    print(typed + 1)
          ~~~~~~^~~
TypeError: can only concatenate str (not "int") to str

Convert the text to a number first: int(typed) + 1.

Cause 2: the wrong number of arguments

def area(length, width):
    return length * width

print(area(5))

What Python says

Traceback (most recent call last):
  File "example.py", line 4, in <module>
    print(area(5))
          ~~~~^^^
TypeError: area() missing 1 required positional argument: 'width'

The function needs two values and was given one. Check the def line and pass every parameter that has no default. The opposite message, "takes 2 positional arguments but 3 were given", means you passed too many.

Inside a class, this message often means the method is missing self as its first parameter.

Cause 3: calling something that is not a function

total = 50
print(total())

What Python says

Traceback (most recent call last):
  File "example.py", line 2, in <module>
    print(total())
          ~~~~~^^
TypeError: 'int' object is not callable

Round brackets after a name mean "call this". A number cannot be called. Remove the brackets.

A sneaky version of this comes from naming a variable after a built-in function.

list = [1, 2, 3]
numbers = list("abc")

What Python says

Traceback (most recent call last):
  File "example.py", line 2, in <module>
    numbers = list("abc")
TypeError: 'list' object is not callable

The first line replaced the built-in list with your own list. The second line then tries to call it. Never use list, str, sum, max, min, len, input or print as variable names.

Cause 4: an index that is not a whole number

names = ["Asha", "Ravi"]
print(names["0"])

What Python says

Traceback (most recent call last):
  File "example.py", line 2, in <module>
    print(names["0"])
          ~~~~~^^^^^
TypeError: list indices must be integers or slices, not str

List positions are integers. "0" in quotation marks is text. This often happens when the index came from input and was not converted with int.

Cause 5: using None as if it were a value

marks = [3, 1, 2]
ordered = marks.sort()
print(ordered[0])

What Python says

Traceback (most recent call last):
  File "example.py", line 3, in <module>
    print(ordered[0])
          ~~~~~~~^^^
TypeError: 'NoneType' object is not subscriptable

sort rearranges the list and returns None. Storing that result gives you None, and None has no item 0. Write marks.sort() on its own line, or use sorted(marks). Whenever a message mentions NoneType, look for a function or method that returned nothing.

Cause 6: comparing things that cannot be compared

print(sorted([3, "two", 1]))

What Python says

Traceback (most recent call last):
  File "example.py", line 1, in <module>
    print(sorted([3, "two", 1]))
          ~~~~~~^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'str' and 'int'

Numbers and text have no natural order between them. Make the list all one type before sorting.

How to find the cause

Print the type of each value on the line that failed.

value = "14"
print(type(value))

Output

<class 'str'>

Once you see <class 'str'> where you expected a number, the fix is a conversion. The types you will convert between most are covered in the lesson on input and type conversion.

Other error messages

Examples on this page were run with Python 3.14 on 12 November 2026. The output shown is the real output.

This is an independent learning site. It is not connected with or approved by the Python Software Foundation. "Python" is a trademark of the Python Software Foundation and is used here only to name the language.