3 ms·
If you replace the assignment in the else clause with something side-effectful it does make sense. But even then it harms the readability of the code to such a
by wesselbindt 1y ago
If you replace the assignment in the else clause with something side-effectful it does make sense. But even then it harms the readability of the code to such a ridiculous extent. I've never not regretted adding an else clause to a for loop. Any cognitive benefits from Python's approach to for loops closely mirroring natural language just go out the window.