Python For Kids · Lesson

Break and Continue

Control your loops effectively

Lesson 4 of 49 steps

Break and Continue is a free Python For Kids lesson on CoddyKit. This is lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Python For Kids learning path, and your progress syncs across the web and the CoddyKit app. The Python For Kids course includes 4 lessons in total.

Controlling Loops with Break and Continue

Break and Continue

Welcome back to the Control Flow lesson! Today, we'll learn how to control your loops more effectively using the break and continue statements.

Break and Continue — illustration 1

What are Break and Continue?

Break and Continue are statements that help you control the flow of loops in your programs.

  • Break: Exits the loop immediately.
  • Continue: Skips the current iteration and moves to the next one.

These statements make your loops more flexible and powerful.

The Break Statement

The break statement stops the loop entirely, even if the loop's condition is still true. It's useful when you want to exit the loop based on a specific condition.

Syntax:

if condition:
    break  # Exits the loop

Example of Break Statement

Let's see how the break statement works with a simple example.

Example:

# Iterates through numbers 1 to 5
for num in range(1, 6):
    if num == 3:
        break  # Exits the loop when num is 3
    print(num)  # Prints the current number

Output of the Break Statement Example

When you run the above code, Python will print the numbers until it reaches 3, then it will exit the loop:

1
2

The Continue Statement

The continue statement skips the current iteration of the loop and moves to the next one. It's useful when you want to skip certain conditions without stopping the entire loop.

Syntax:

if condition:
    continue  # Skips to the next iteration

Example of Continue Statement

Here's how the continue statement works with a simple example.

Example:

# Iterates through numbers 1 to 5
for num in range(1, 6):
    if num == 3:
        continue  # Skips the number 3
    print(num)  # Prints the current number

for i in range(1, 5):
    if i == 2:
        continue
    if i == 4:
        break
    print(i)

Great Job!

You've learned how to use break and continue statements to control your loops in Python. These tools help you manage how your loops execute, making your programs more efficient and effective.

Keep practicing by incorporating these statements into your own loops to see how they can enhance your programs!

Free to start

Learn Python with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
22
Lessons
94

Frequently Asked Questions

Is the “Break and Continue” lesson free?

Yes — the full text of “Break and Continue” is free to read here on the web. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Python For Kids course, upgrade to CoddyKit PRO. The Python For Kids course includes 4 lessons in total.

What will I learn in “Break and Continue”?

Control your loops effectively You practise Python For Kids with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Python For Kids?

No prior experience is required. Python For Kids on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 4 of 4.

How long does the “Break and Continue” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Python For Kids lesson?

Yes. Every Python For Kids lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. If-Else Statements
  2. Loops in Python
  3. Nested Loops
  4. Break and Continue
← Back to Python For Kids