TypeError: 'dict' object is not callable (Fix)

Fix the Python error TypeError: 'dict' object is not callable. This page explains what the error means, the most common causes, and how to correct your code with simple examples.

Quick fix

This error often happens when you use parentheses () with a dictionary. Use square brackets [] to access a value by key.

my_dict = {'a': 1}

# Wrong
# value = my_dict('a')

# Correct
value = my_dict['a']
print(value)

Output:

1

What this error means

  • Python is treating a dictionary like a function.
  • A dictionary stores key-value pairs, but you cannot call it with ().
  • If you see this error, check where you used parentheses after a variable name.

For example, this causes the error:

user = {'name': 'Sam'}

print(user('name'))

Because user is a dictionary, not a function.

If you need a refresher, see Python dictionaries explained.

Common cause: using () instead of []

Use square brackets to get a value from a dictionary by key.

Wrong:

user = {'name': 'Sam'}
print(user('name'))

Correct:

user = {'name': 'Sam'}
print(user['name'])

Output:

Sam

If the key may not exist, use .get() instead:

user = {'name': 'Sam'}

print(user.get('name'))
print(user.get('age'))

Output:

Sam
None

You can learn more on the Python dictionary get() method.

Common cause: variable name hides a function

You may have used the same name for a dictionary and a function.

A very common mistake is naming a variable dict:

dict = {'a': 1}

print(dict())

This fails because dict now refers to your dictionary, not Python’s built-in dict() function.

Fix

Rename the variable to something clearer:

data = {'a': 1}

new_dict = dict()
print(data)
print(new_dict)

Output:

{'a': 1}
{}

Using names like data, user_info, or settings helps avoid this problem.

If needed, see Python dict() function explained.

Common cause: accidental extra parentheses

Sometimes the dictionary access is correct, but extra () are added after it.

Example:

settings = {'theme': 'dark'}

print(settings['theme']())

This only works if settings['theme'] is a function. Here, it is a string, so Python raises an error.

Fix

Remove the extra parentheses:

settings = {'theme': 'dark'}

print(settings['theme'])

Output:

dark

When calling a dictionary value is valid

A dictionary can store functions:

def greet():
    return "Hello"

actions = {'say_hello': greet}

print(actions['say_hello']())

Output:

Hello

The key point is:

  • actions is a dictionary, so actions() is wrong
  • actions['say_hello'] is a function, so actions['say_hello']() is valid

How to fix it step by step

  1. Find the line shown in the traceback.
  2. Look for a dictionary variable followed by ().
  3. Replace () with [] if you are accessing a key.
  4. Check whether you overwrote a built-in name like dict.
  5. Print type(variable) if you are not sure what the variable contains.

Example:

data = {'name': 'Ava'}

print(type(data))
print(data['name'])

Output:

<class 'dict'>
Ava

How to debug this error

  • Read the full traceback to find the exact line.
  • Print the variable before the failing line.
  • Use type(variable) to confirm it is a dictionary.
  • Check earlier code for variables named dict or other function names.

Useful debugging commands:

my_dict = {'a': 1, 'b': 2}

print(my_dict)
print(type(my_dict))
print(my_dict.keys())
print(locals())

These help you confirm:

  • what the variable contains
  • whether it is really a dictionary
  • which keys are available
  • what names exist in the current scope

Common mistakes

These are the most common reasons for this error:

  • Using my_dict('key') instead of my_dict['key']
  • Naming a variable dict and then trying to call dict()
  • Adding extra parentheses after a dictionary value
  • Expecting a dictionary value to be a function when it is not

FAQ

Why does Python say a dict object is not callable?

Because your code used parentheses after a dictionary, and parentheses are used to call functions.

How do I access a dictionary value correctly?

Use square brackets with a key, like data['name'], or use data.get('name').

Can a dictionary store functions?

Yes. If a dictionary value is a function, then calling that value can work. But the dictionary itself is still not callable.

What if I named my variable dict?

Rename it to another name, because dict is also the name of a built-in Python function.

See also