Python uses the continue statement to jump out of the loop, while the break jumps out of the entire loop. The continue statement is used to tell Python to skip the remaining statement of the current loop and then continue the next loop. The continue statement is used in the while and for loops.
1. The syntax format of the Python continue statement is as follows:
Copy codeThe Code is as follows: continue
Ii. Logic flowchart:
Iii. instances used:
Copy codeThe Code is as follows :#! /Usr/bin/python
For letter in 'python': # First Example
If letter = 'H ':
Continue
Print 'current Letter: ', letter
Var = 10 # Second Example
While var> 0:
Var = var-1
If var = 5:
Continue
Print 'current variable value: ', var
Print "Good bye! "
Execution result of the above instance:
Copy codeThe Code is as follows:
Current Letter: P
Current Letter: y
Current Letter: t
Current Letter: o
Current Letter: n
Current variable value: 9
Current variable value: 8
Current variable value: 7
Current variable value: 6
Current variable value: 4
Current variable value: 3
Current variable value: 2
Current variable value: 1
Current variable value: 0
Good bye!