Next →

What is 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 += 1

This prints numbers from 0 to 3, then stops.

What is 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.

Why This Matters in Analytics

You might want to skip invalid data or stop processing once a condition is met. break and continue give you fine control over loops.