.. _consider-using-dict-items:

consider-using-dict-items / C0206
=================================

**Message emitted:**

Consider iterating with .items()

**Description:**

*Emitted when iterating over the keys of a dictionary and accessing the value by index lookup. Both the key and value can be accessed by iterating using the .items() method of the dictionary instead.*

**Problematic code:**

.. literalinclude:: /data/messages/c/consider-using-dict-items/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/c/consider-using-dict-items/good.py
   :language: python



Created by the `refactoring <https://github.com/PyCQA/pylint/blob/main/pylint/checkers/refactoring/recommendation_checker.py>`__ checker.