.. _consider-refactoring-into-while-condition: consider-refactoring-into-while-condition / R3501 ================================================= **Message emitted:** ``Consider using 'while %s' instead of 'while %s:' an 'if', and a 'break'`` **Description:** *Emitted when `while True:` loop is used and the first statement is a break condition. The ``if / break`` construct can be removed if the check is inverted and moved to the ``while`` statement.* **Problematic code:** .. literalinclude:: /data/messages/c/consider-refactoring-into-while-condition/bad.py :language: python **Correct code:** .. literalinclude:: /data/messages/c/consider-refactoring-into-while-condition/good.py :language: python **Configuration file:** .. literalinclude:: /data/messages/c/consider-refactoring-into-while-condition/pylintrc :language: ini .. note:: This message is emitted by the optional :ref:`'consider_refactoring_into_while'` checker, which requires the ``pylint.extensions.consider_refactoring_into_while_condition`` plugin to be loaded. Created by the `consider_refactoring_into_while `__ checker.