I was using Python 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609] on linux2 , when i ran the folllowing code in it the corresponding error is shown .I searche
In a fresh interpreter:
>>> bob=dict(name='bob smith',age=42,pay='10000',job='dev')
>>> bob
{'age': 42, 'pay': '10000', 'job': 'dev', 'name': 'bob smith'}
However, you are getting a TypeError
:
TypeError: 'dict' object is not callable
This error you get tells you that your dict
is not callable.
Since my dict
is callable when I open a fresh interpreter, it means that your dict
is different.
Most likely, you defined a dict
variable, which overrode the built-in dict
. Look for the
dict = {...}
line, and rename your variable.
As pointed out by @Robᵩ, don't use built-in names for your variables. Especially avoid the tempting str
, list
, and so on.