.. _invalid-format-index:

invalid-format-index / W1307
============================

**Message emitted:**

Using invalid lookup key %r in format specifier %r

**Description:**

*Used when a PEP 3101 format string uses a lookup specifier ({a[1]}), but the argument passed for formatting doesn't contain or doesn't have that key as an attribute.*

**Problematic code:**

.. literalinclude:: /data/messages/i/invalid-format-index/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/i/invalid-format-index/good.py
   :language: python



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