.. _invalid-length-returned:

invalid-length-returned / E0303
===============================

**Message emitted:**

__len__ does not return non-negative integer

**Description:**

*Used when a __len__ method returns something which is not a non-negative integer*

**Problematic code:**

.. literalinclude:: /data/messages/i/invalid-length-returned/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/i/invalid-length-returned/good.py
   :language: python



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