Python throws error, ‘dict’ object has no attribute ‘iteritems’, because iteritems()
function is removed from Python 3. Similarly, functions like iterkeys()
and itervalues()
are also removed.
According to Python3.0 Built-in changes documentation –
Remove dict.iteritems(), dict.iterkeys(), and dict.itervalues(). Instead: use dict.items(), dict.keys(), and dict.values() respectively.
So, instead of .iteritems()
you can use .items()
.
You encounter this error when you are migrating from Python 2 to Python 3. There are many other changes which you can see in the documentation link, I shared above.
#python #error #python error #python-short