Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3
Hi,Rene ! It’s a part of Python’s syntax and is called “for-else” or “loop-else” (it works with while loops as well). It’s perfect in situations where you might have used flags previously. The else block is executed if the loop is not interrupted by a break statement.
13th Dec 2023, 10:43 PM
Per Bratthammar
Per Bratthammar - avatar