Break/Continue in a Nested Loop | Nested Loops
Python Loops Tutorial

Course Content

Python Loops Tutorial

Python Loops Tutorial

1. The for Loop
2. The while Loop
3. Nested Loops

Break/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.

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.

Everything was clear?

Section 3. Chapter 6

Break/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.

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.

Everything was clear?

Section 3. Chapter 6

Break/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.

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.

Everything was clear?

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?

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.