Using break to exit loop early Dry Run in PYTHON

Using break to exit loop early is an interactive PYTHON dry run visualizer from the While programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Using break to exit loop early Program Code

# Break to exit loop when condition met
numbers = [1, 3, 5, 7, 8, 9, 11]
i = 0

while i < len(numbers):
    print(f"Checking {numbers[i]}")
    if numbers[i] % 2 == 0:
        print(f"Found first even number: {numbers[i]}")
        break
    i += 1
else:
    print("No even number found")

print("Loop ended")

View the complete While programs page.

Program Console Using break to exit loop early Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.