Course Content
Python Loops Tutorial
Python Loops Tutorial
Break/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?

Task
Halt the loop when encountering a negative value.
- Initialize a
while
loop, employingi
to interact withnumbers
. - Increment the value of
i
. - Display a message along with the negative element.
- Employ
break
andcontinue
as needed.
Everything was clear?
Section 2. Chapter 5