Show break, continue and pass in one loop, and describe what each one does to the loop.
All three of them are loop control statements, but they change the loop in completely different ways. break ends the loop, continue moves on to the next round, and pass does nothing at all.
for number in range(1, 8):
if number == 3:
continue # skip the rest of this round
if number == 6:
break # leave the loop completely
print(number, end=' ')
print()
# pass is a placeholder that does nothing.
class Placeholder:
pass
for character in 'abc':
pass # legal, but it does nothing
The output is 1 2 4 5 followed by a newline. The continue skips the round where the number is 3, so 3 is never printed, and then the loop carries on. The break at the number 6 stops the loop completely, so 6 and 7 are never reached even though the range goes all the way up to 7.
The important subtlety is that continue skips the rest of the current round only. Any code after the continue in the same loop body is skipped for that one pass, and then the loop condition is checked again. If the continue sits at the end of the body it does nothing useful, and if it sits before an important update you can end up with a loop that never ends.
pass is the odd one out here. It exists because Python has no empty block, so an if with no body would be a syntax error. pass gives you a legal empty body. It is a placeholder for code that you have not written yet, for a class that you intend to fill in later, and for the branch of an if chain that only holds a comment.