---
source: crates/ruff/src/rules/pylint/mod.rs
---
useless_else_on_loop.py:9:5: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it
   |
 9 |         if i % 2:
10 |             return i
11 |     else:  # [useless-else-on-loop]
   |     ^^^^ PLW0120
12 |         print("math is broken")
13 |     return None
   |

useless_else_on_loop.py:18:5: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it
   |
18 |     while True:
19 |         return 1
20 |     else:  # [useless-else-on-loop]
   |     ^^^^ PLW0120
21 |         print("math is broken")
22 |     return None
   |

useless_else_on_loop.py:30:1: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it
   |
30 |             break
31 | 
32 | else:  # [useless-else-on-loop]
   | ^^^^ PLW0120
33 |     print("or else!")
   |

useless_else_on_loop.py:37:1: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it
   |
37 |     while False:
38 |         break
39 | else:  # [useless-else-on-loop]
   | ^^^^ PLW0120
40 |     print("or else!")
   |

useless_else_on_loop.py:42:1: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it
   |
42 | for j in range(10):
43 |     pass
44 | else:  # [useless-else-on-loop]
   | ^^^^ PLW0120
45 |     print("fat chance")
46 |     for j in range(10):
   |

useless_else_on_loop.py:88:5: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it
   |
88 |             else:
89 |                 print("all right")
90 |     else:  # [useless-else-on-loop]
   |     ^^^^ PLW0120
91 |         return True
92 |     return False
   |

useless_else_on_loop.py:98:9: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it
    |
 98 |         for _ in range(3):
 99 |             pass
100 |         else:
    |         ^^^^ PLW0120
101 |             if 1 < 2:  # pylint: disable=comparison-of-constants
102 |                 break
    |


