.. _compare-to-zero:

compare-to-zero / C2001
=======================

**Message emitted:**

Avoid comparisons to zero

**Description:**

*Used when Pylint detects comparison to a 0 constant.*

**Problematic code:**

.. literalinclude:: /data/messages/c/compare-to-zero/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/c/compare-to-zero/good.py
   :language: python




.. note::
  This message is emitted by the optional :ref:`'compare-to-zero'<pylint.extensions.comparetozero>` checker which requires the ``pylint.extensions.comparetozero``
  plugin to be loaded.

Created by the `compare-to-zero <https://github.com/PyCQA/pylint/blob/main/pylint/extensions/comparetozero.py>`__ checker.