0% found this document useful (0 votes)
16 views17 pages

Countinue Statement

Uploaded by

revanthch121
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views17 pages

Countinue Statement

Uploaded by

revanthch121
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

COUNTINUE

STATEMENT
CH.REVANTH(CSM)
21951A66A6
THE TOPICS PRESENT IN THIS SLIDESHOW :

• What is continue statement ?


• Usage of continue statement
• Flow diagram in python
• Example of continue statement
• Python continue statement in for while loop
example
What is continue statement :

• The continue statement is used inside a loop to skip the


rest of the statements in the body of loop for the
current iteration and jump to the beginning of the loop
for next iteration.

• The break and continue statements are used to alter


the flow of loop, break terminates the loop when a
condition is met and continue skip the current iteration.
Continue statement is a loop control statement that
forces to execute the next iteration of the loop while
skipping the rest of the code inside the loop for the
current iteration only i.e. when the continue
statement is executed in the loop, the code inside the
loop following the continue statement will be skipped
for the current iteration and the next iteration of the
loop will begin.
• The continue statement in Python is used to bring the
program control to the beginning of the loop. The
continue statement skips the remaining lines of code
inside the loop and start with the next iteration
• The continue statement skips the remaining lines of code
inside the loop and start with the next iteration.
• It is mainly used for a particular condition inside the
loop so that we can skip some specific code for a
particular condition.
• The Python continue statement is another one to control
the flow of loops.
• This Python continue statement is used inside For and
While Loops.
• While executing these iterables, if compiler find this
statement inside them, then compiler will stop the
current iteration and starts the new iteration from the
beginning.
Usage of continue statement :

• Loops in Python automates and repeats the tasks in


an efficient manner. But sometimes, there may arise
a condition where you want to exit the loop
completely, skip an iteration or ignore that condition.

• These can be done by loop control statements.


Continue is a type of loop control statement that can
alter the flow of the loop.
Flow chart of contine statement :
Example of continue statement :
Consider the situation when you need to write a program which prints the
number from 1 to 10 and but not 6. It is specified that you have to do this
using loop and only one loop is allowed to use.

Here comes the usage of continue statement. What we can do here is we


can run a loop from 1 to 10 and every time we have to compare the value of
the iterator with 6. If it is equal to 6 we will use the continue statement to
continue to the next iteration without printing anything otherwise we will
print the value.
• example 2 :
• Lets say we have a list of numbers and we want to print only
the odd numbers out of that list. We can do this by using
continue statement.
• We are skipping the print statement inside loop by using
continue statement when the number is even, this way all the
even numbers are skipped and the print statement executed for
all the odd numbers.
Python continue in while loop
• In this example we will example
show you, How to :
use Python continue Statement
inside the While Loop with example. This program will iterate from 1 to 10
and print every number up to 10. We also used if condition to skip few
numbers.
Python continue Statement in For Loop
Example

How to use Python continue Statement inside the For Loop?.


This program allows the user to enter any integer values.
Next, it will display the Even and Odd numbers inside the
integer value.

In this python for loop continue example, it will ask the user
to enter integer number and stores in number. In the next
line we used the For Loop with range.
• Please refer Break code to understand the
implementation of the Python break inside the For and
While loop.

• Inside it, we placed If condition to test whether (i%2 !


= 0). If this condition is True then python continue
statement in for loop will be executed and the
iteration will stop at that number without printing the
other print statement: print(” Even numbers = “, i).
• For better understanding, we placed a print message inside the
If. So, whenever the iteration breaks then that value be printed
from this print function.
If the condition is false, it will skip this, and prints that number
as output (In Our case Even Number) using the following block of
code.

You might also like