Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Break/Continue in a while Loop | The while Loop
course content

Contenido del Curso

Python Loops Tutorial

Break/Continue in a while LoopBreak/Continue in a while Loop

Now, we'll attempt the same task we previously accomplished with the for loop—finding a number in the list and terminating the loop once it's located.

Examine the code below:

How does the code work?

Great!

Please be aware that the continue statement skips a block of code within the loop for the current iteration only. Now, let's count the occurrences of 11s in the code using continue.

Examine the code below:

How does the code work?

Tarea

Halt the loop when encountering a negative value.

  1. Initialize a while loop, employing i to interact with numbers.
  2. Increment the value of i.
  3. Display a message along with the negative element.
  4. Employ break and continue as needed.

¿Todo estuvo claro?

Sección 2. Capítulo 5
toggle bottom row
course content

Contenido del Curso

Python Loops Tutorial

Break/Continue in a while LoopBreak/Continue in a while Loop

Now, we'll attempt the same task we previously accomplished with the for loop—finding a number in the list and terminating the loop once it's located.

Examine the code below:

How does the code work?

Great!

Please be aware that the continue statement skips a block of code within the loop for the current iteration only. Now, let's count the occurrences of 11s in the code using continue.

Examine the code below:

How does the code work?

Tarea

Halt the loop when encountering a negative value.

  1. Initialize a while loop, employing i to interact with numbers.
  2. Increment the value of i.
  3. Display a message along with the negative element.
  4. Employ break and continue as needed.

¿Todo estuvo claro?

Sección 2. Capítulo 5
toggle bottom row
some-alt