continue

noun

say it: “kun-TIN-yoo” /kənˈtɪnjuː/

A Python keyword that skips the rest of this pass through a loop and goes on to the next item.

What does continue do?

continue skips the rest of this pass through the loop and jumps to the next item.

for price in [5, -1, 8]:
    if price < 0:
        continue        # skip bad data
    print("Price:", price)

In a sentence

  • “Negative prices are bad data, so the loop uses continue to skip them.”
  • “continue skipped the blank lines in the file and went on to the next one.”

Level: Apprentice · More Python terms at this level

Updated

In other subjects