Skip to content

How to Fix TypeError: 'int' object is not callable in Python

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about How to Fix TypeError: 'int' object is not callable in Python. We cover key concepts, practical examples, and best practices.

Python raises TypeError: 'int' object is not callable when you try to call an integer as if it were a function -- usually because a variable named max, sum, or int overwrites the built-in function.

The Wrong Way

max = 10
print(max(5, 8))

This produces:

Traceback (most recent call last):
  File "script.py", line 2, in <module>
    print(max(5, 8))
TypeError: 'int' object is not callable

The Right Way

Avoid naming variables after built-in functions:

max_value = 10
print(max(5, 8))

Output:

8

Step-by-Step Fix

1. Identify the shadowing variable

Search your code for variable names that match built-in functions: max, min, sum, int, str, list, dict, set, type, input, print, len, range, zip, map, filter, sorted, reversed, open, file, id, dir.

# Wrong
list = [1, 2, 3]
new_list = list(range(5))  # TypeError

# Right
my_list = [1, 2, 3]
new_list = list(range(5))
print(new_list)

Output:

[0, 1, 2, 3, 4]

2. Restart the interpreter if needed

If you accidentally overwrote a built-in in an interactive session, restart the interpreter or delete the shadowing variable:

del max

3. Use a linter to catch shadowing

pip install flake8
flake8 script.py

Flake8 reports E741 for ambiguous variable names and can help catch shadowing with custom rules.

4. Check for missing operators

# Wrong -- missing multiplication operator
result = 5(3 + 2)

# Right
result = 5 * (3 + 2)

Prevention Tips

  • Never name a variable after a Python built-in function.
  • Use a linter with shadowing detection enabled.
  • Use IDE features that highlight when you override a built-in.
  • Adopt naming conventions like max_value, str_content instead of max, str.
  • Run python3 -W error::DeprecationWarning in CI to catch issues early.

Common Mistakes with typeerror

  1. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
  2. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  3. Misunderstanding that String is [Char] with poor performance for large text operations

These mistakes appear frequently in real-world PYTHON code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What does "object is not callable" mean?

It means you used parentheses () on a value that does not support function-call syntax. Only functions, classes, and objects with a __call__ method can be called with parentheses.

Can this error happen with strings?

Yes. str = "hello"; print(str("world")) produces the same error because str is now a string, not the built-in function. The same principle applies to any overwritten built-in.

How do I restore a built-in after overwriting it?

Use del variablename to remove the shadowing variable, or restart the Python interpreter. In scripts, simply rename the conflicting variable and re-run the script.

Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro