Read Python Interview Questions and Answers for Beginners and Experienced

Python Continue Keyword

Python Continue keyword is one of the Python Keyword used to help the flow to be continue when some conditions is 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 the requirement of printing odd numbers from 1 to 10, In this example, we will check odd numbers by using modulus, if the 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 the flow of the program without breaking it.