.. _invalid-sequence-index:

invalid-sequence-index / E1126
==============================

**Message emitted:**

Sequence index is not an int, slice, or instance with __index__

**Description:**

*Used when a sequence type is indexed with an invalid type. Valid types are ints, slices, and objects with an __index__ method.*

**Problematic code:**

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

**Correct code:**

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

**Additional details:**

Be careful with ``[True]`` or ``[False]`` as sequence index, since ``True`` and ``False`` will respectively
be evaluated as ``1`` and ``0`` and will bring the second element of the list and the first without erroring.


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