.. _use-implicit-booleaness-not-len:

use-implicit-booleaness-not-len / C1802
=======================================

**Message emitted:**

Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty

**Description:**

*Used when Pylint detects that len(sequence) is being used without explicit comparison inside a condition to determine if a sequence is empty. Instead of coercing the length to a boolean, either rely on the fact that empty sequences are false or compare the length against a scalar.*

**Problematic code:**

.. literalinclude:: /data/messages/u/use-implicit-booleaness-not-len/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/u/use-implicit-booleaness-not-len/good.py
   :language: python



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