Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Break/Continue in a Nested Loop | Nested Loops
Python Loops Tutorial

Break/Continue in a Nested LoopBreak/Continue in a Nested Loop

If the break statement is employed within a nested loop, it will terminate the innermost loop.

Examine the code below:

How does the code work?

Please note that when the continue statement is encountered inside the loop, it skips all the statements below it and immediately moves to the next iteration.

Examine the code below:

How does the code work?

Завдання

You need to filter out symbols and numbers from the given list.

  1. Configure the outer for loop to iterate through the number of rows in the matrix.
  2. Configure the inner for loop to iterate through the elements in each row of the matrix.
  3. Implement the following conditions: If an element is '#', then continue the loop; else if an element is '!', then break out of the loop; if an element is neither '#' nor '!', then print this element.

Все було зрозуміло?

Секція 3. Розділ 6
toggle bottom row
course content

Зміст курсу

Python Loops Tutorial

Break/Continue in a Nested LoopBreak/Continue in a Nested Loop

If the break statement is employed within a nested loop, it will terminate the innermost loop.

Examine the code below:

How does the code work?

Please note that when the continue statement is encountered inside the loop, it skips all the statements below it and immediately moves to the next iteration.

Examine the code below:

How does the code work?

Завдання

You need to filter out symbols and numbers from the given list.

  1. Configure the outer for loop to iterate through the number of rows in the matrix.
  2. Configure the inner for loop to iterate through the elements in each row of the matrix.
  3. Implement the following conditions: If an element is '#', then continue the loop; else if an element is '!', then break out of the loop; if an element is neither '#' nor '!', then print this element.

Все було зрозуміло?

Секція 3. Розділ 6
toggle bottom row
some-alt