Int Object Is Not Callable | Fix The Error Fast

The “int object is not callable” error happens when code uses parentheses on an integer because a function name got replaced or brackets were needed.

You run a script, hit Enter, and Python throws a TypeError that seems to come from nowhere. Annoying, sure. The upside is that this one is rarely mysterious. Python is telling you that the thing right before () is an integer at runtime, so calling it can’t work.

This article explains what Python means by that message, the causes that show up most often, and a set of checks you can repeat on any project. The aim is simple: find the name that became an integer, then bind that name back to the callable you meant to use.

You’ll see short code snippets you can match to your own traceback, plus fixes that work in scripts, notebooks, and bigger codebases.

What The Error Means In Plain Terms

Python treats parentheses as a call. Functions, methods, classes, and any object that defines __call__ can be written like thing(). An integer can’t.

When Python reaches a line like n(), it checks what n points to right then. If n is an int, you get TypeError: 'int' object is not callable. The message tells you what n is at the moment the call happens, not what you hoped it was.

Most fixes fall into one of these patterns:

  • Use Brackets For Indexing — Write items[0] when you mean “first item.”
  • Call The Right Name — Call the function, not a variable that stores its result.
  • Stop Reusing Names — Don’t assign a number to a name you still need as a function.

Int Object Is Not Callable With Common Triggers

This error usually comes from a small set of triggers. Spot the one that matches your code, then apply the matching fix.

Reusing A Built-In Name

Built-ins like sum, len, max, and min are functions. If you store an integer in one of those names, later calls break.

sum = 10
print(sum([1, 2, 3]))  # TypeError
  • Rename The Variable — Use total_sum or count, then rerun from the top.
  • Delete The Shadow Name — In a REPL or notebook, run del sum to restore the built-in in that scope.

Overwriting Your Own Function Name

You define a function, then later assign a number to the same name. The function still exists in the file, yet the name now points at an integer.

def price_with_tax(x):
    return int(x * 1.07)

price_with_tax = 20
price_with_tax(10)  # TypeError
  • Separate The Names — Keep price_with_tax for the function and use price for the value.
  • Search Assignments — Find price_with_tax = and remove the collision.

Mixing Up Parentheses And Brackets

Parentheses call. Brackets index. If items is a list, tuple, NumPy array, or pandas Series, you nearly always want brackets.

items = [10, 20, 30]
first = items(0)  # TypeError
  • Switch To Brackets — Use items[0] or items[-1].
  • Check The Type — Print type(items) right before the failing line.

Calling A Stored Value

A name that holds a number can read like a function name. A quick check is to print the name and its type before you call it.

count = len([1, 2, 3])
count()  # TypeError
  • Drop The Parentheses — Use count as a value.
  • Call The Real Function — Use len(items) when you need a length.

Shadowing An Import

You import something callable, then reuse the imported name for an integer. This bites in longer files because the reassignment can be far from the traceback line.

from math import floor
floor = 5
floor(2.9)  # TypeError
  • Rename The Counter — Use n_floors or floors for counts.
  • Reimport After Cleanup — In a notebook, run the import cell again after deleting the name.

Loop Variables That Quietly Replace A Name

A loop can replace a name inside its scope. If you use a built-in name as your loop variable, the call inside the loop will break.

for sum in [1, 2, 3]:
    print(sum([1, 2, 3]))  # TypeError
  • Rename The Loop Variable — Use n, x, or a clearer noun, then rerun.
  • Scan Comprehensions Too — A list comprehension can shadow a name the same way.

Quick Checks That Pinpoint The Line

A traceback shows where Python noticed the problem. The cause can sit earlier in the run. These checks narrow it down fast.

  1. Read The Token Before Parentheses — Copy the exact name right before (). That is the object Python tried to call.
  2. Print The Type Near The Failure — Add print(type(name), name) on the line above, then rerun.
  3. Search For Reassignment — Use editor search for name = and check each match.
  4. Check Parameters — A function parameter can shadow an imported callable with the same name.
  5. Restart In Notebooks — Stale variables from older cells can stick around and surprise you.

If you can’t see the reassignment, add a small guard right after imports: assert callable(sum). It stops the run the moment a name changes into a non-callable value.

When the failure is inside a library call, assume you passed an integer where a callback was expected. Print the value right before you hand it off and confirm callable(value) returns True.

Fix Patterns You Can Apply Right Away

Once you know the trigger, the fix is usually a rename or a syntax swap. These patterns map to what you see in real projects.

Rename Values And Keep Verbs For Functions

Verb-style names tempt you to call them. Noun-style names read like values. This small naming habit prevents a lot of accidental calls.

def get_count(items):
    return len(items)

count = get_count([1, 2, 3])
print(count)           # value
print(get_count([4]))  # call
  • Use Verb Names For Callables — Names like get_count signal a call.
  • Use Noun Names For Values — Names like count signal reading.

Split A Long Chain Into Steps

Some APIs return integers mid-chain, then the next () fails. Splitting the chain shows what each part returns.

step = obj.method()
print(type(step), step)
value = step(x)  # only valid if step is callable
  • Store Intermediate Results — Save each step in a variable so you can inspect it.
  • Inspect Before Calling — If callable(step) is false, don’t use () on it.

Use The Right Indexing For Pandas

With pandas, parentheses are not indexing. Use accessors so you stay clear about whether you’re reading by position or by label.

  • Use Iloc For Positiondf.iloc[row, col] reads by integer position.
  • Use Loc For Labelsdf.loc[label] reads by index label.
  • Print Types At The Boundary — If a helper returns a Series, treat it like data, not a function.

Repair A Shadowed Built-In In A Notebook

In a notebook session, you can restore a built-in name without rewriting a lot of code. This is handy when you just want to keep moving.

len = 12
# del len
items = [1, 2, 3]
print(__builtins__.len(items))
  • Delete The Shadow Name — Run del len after you stop using the variable.
  • Rerun Imports — A clean run resets names in the expected order.

Fix Scope Mix-Ups In Nested Functions

A nested function can read a name from an outer scope. If you assign to that name later, the value can change in ways that surprise you. When debugging, print the suspect name inside the inner function right before it is called.

def outer():
    handler = lambda x: x + 1
    handler = 3
    return handler(10)  # TypeError
  • Keep Callables In Dedicated Names — Use a name like handler_fn for the callable.
  • Print Inside The Scope — Log type(handler) where the call happens, not where you defined it.

Common Causes And Fixes At A Glance

This table pairs the usual symptom with a cause and a fix. It’s short on purpose, so you can scan it while debugging.

What You See Likely Cause Fix That Works
sum(...) fails sum holds an int Rename the variable, or del sum in a REPL
items(0) fails Call syntax used on a list Use items[0]
my_func() fails after assignment Function name overwritten Rename the value, rerun from top
Works once, fails later in a notebook Old state in earlier cells Restart kernel, run all cells
Import name fails after counting Imported callable shadowed Pick a new counter name, reimport

Habits That Stop The Error From Coming Back

Once you fix the bug, a few habits keep it from showing up again. None of these are heavy. They just make name collisions less likely.

  • Avoid Built-In Names — Skip names like sum, max, min, len, list, dict, and id.
  • Use Clear Value Names — Names like total, count, size, limit, and index read like numbers.
  • Lint Early — Tools like ruff and pylint warn when you shadow built-ins.
  • Type Hint Hot Spots — A hint like count: int can trigger editor warnings before runtime.
  • Write Small Tests — A tiny test that calls the function once catches name collisions after refactors.

When you hit the error again, do the same two-step move: find the name before (), then print its type right above the failing line. That pattern works quickly, even on messy code.

If you found this page by searching for int object is not callable, the fix is usually a renamed variable or a bracket swap on a list, array, or Series.