Python Continue

Python Continue is one of Python Keyword used to help the flow to be continue when some condition met. As it is cleared from name continue, it continues the flow of program when condition met.

 

Example of Continue:

Let’s understand continue with taking an example.

Let’s assume we have requirement of printing odd numbers from 1 to 10, In this example, we will check odd number by using modulus, if number is totally divided by zero, then we continue to take another number.

 

#Python continue keyword example 

for x in range (1,11) :
    if x%2==0 :
        continue
    print(x)

Output

1

3

5

7

9

 

Here continue helps to move the for loop one step ahead.

 

So, Python continue helps to continue flow the program without breaking it.

Please follow and like us:
READ  Python del