TryBugHunt

TypeError: 'dict' object is not callable

TypeError: 'dict' object is not callable in Python means you tried to call a dictionary like a function with parentheses (), or a variable named dict shadowed the built-in dict type.

PythonPattern: Type errors

How do I fix TypeError: 'dict' object is not callable?

To fix TypeError: 'dict' object is not callable in Python, locate the line causing the error and check the values right before it runs. Most occurrences happen because of accessing a dictionary key with parentheses. Apply a defensive check or safe fallback, make sure collections or objects exist before access, and verify return values from upstream functions.

1. Inspect bounds & typesPrint or inspect collection sizes and verify variables are not empty or None/undefined.
2. Guard with safe accessUse optional chaining (?.), dictionary get(), or guard conditions before dereferencing.
3. Trace upstream originsFind where the value was instantiated or returned rather than only patching the symptom.

What does TypeError: 'dict' object is not callable mean?

Parentheses () in Python mean "execute this function". Dictionary lookups require square brackets [key] or the .get(key) method. When you write my_dict("key"), Python thinks you are attempting to invoke the dictionary as a callable object.

Why does TypeError: 'dict' object is not callable happen?

1. Accessing a dictionary key with parentheses

Lookups use square brackets ["key"], not round parentheses ("key").

Breaks

user = {"name": "Alice", "age": 30}
name = user("name")

Works

user = {"name": "Alice", "age": 30}
name = user["name"]

2. Overwriting the built-in dict function

Assigning to a variable named dict overrides the constructor.

Breaks

dict = {"a": 1}
copy = dict([("b", 2)])

Works

my_dict = {"a": 1}
copy = dict([("b", 2)])

3. Missing an operator or method call

A missing method name between a dictionary and arguments looks like a call.

Breaks

val = data("items", 0)

Works

val = data.get("items", 0)

How to find it in your own code

Replace parentheses () with square brackets [] when looking up dictionary keys, and rename any variable named `dict` to something descriptive like `user_data` or `config`.

Try it: fix this bug

easy

format_price(5) crashes: TypeError: can only concatenate str (not "int") to str.

def format_price(amount):
    return "$" + amount
Open with hintsRuns in your browser. No account needed.

More challenges with this error

Each of these challenges runs into this error or pattern. Find the bug and fix it in your browser โ€” no install, no account needed.

Still not sure why yours breaks?

Paste it into the visualizer and watch it run line by line, with every variable at every step. Free, and it runs in your browser.

Related error guides

View all type errors โ†’