For Loop with break

1 min read ·

The break statement is used to stop a for loop immediately, even if items are still left to iterate.

Basic Syntax


Simple Example


break with String Loop


break with List


break with User Input


Key Point

Note

break exits the loop completely, not just the current iteration.


Exercise