Skip to content
← Index | Lesson 4 of 5

break and continue

break and continue

break exits the loop, continue skips to the next iteration:

for i in 0..10 {
    if i % 2 == 0 { continue } // skip evens
    if i > 7 { break }          // stop at 7
    print(i) // 1, 3, 5, 7
}

Goal: Print only the multiples of 3 between 1 and 30.

lesson-3-4.zolo
Program output

Run the code to see the output

Search Zolo

9 results

enespt-br