3 ms·
Your suggested replacement duplicates the break condition, which is not ideal for maintainability. Also, it only happens to work due to Python's variable scopi
by fyi1183 8y ago
Your suggested replacement duplicates the break condition, which is not ideal for maintainability.
Also, it only happens to work due to Python's variable scoping rules. I have wished for a for-else construct in C and C++ many times: having to broaden the scope of a loop iteration variable just to duplicate a loop break check really sucks.