break?The break statement immediately stops a loop, even if the loop’s condition is still true.
Example:
count = 0
while True:
print(count)
if count == 3:
break
count += 1This prints numbers from 0 to 3, then stops.
continue?The continue statement skips the rest of the current loop iteration and moves to the next one.
Example:
for i in range(5):
if i == 2:
continue
print(i)This prints 0, 1, 3, 4 — skipping 2.
You might want to skip invalid data or stop processing once a condition is met. break and continue give you fine control over loops.