The Python continue statement returns the start of a while loop. The continue statement rejects the rest of the statement execution in the current iteration of the loop and moves the control back to the top of the loop (the start position).
The continue statement can be used in while and for loops.
Grammar
The syntax for the Python continue statement is as follows:
Continue
Flow chart:
Example
#!/usr/bin/pythonfor "Python": # First Example if letter = = ' h ': continue print ' current Letter: ', Lettervar = ten # Second examplewhile var > 0: var = var-1 If var = = 5: Continue print ' Current variable value: ', varprint "good bye!"
When the above code is executed, the following results are produced:
Current letter:pcurrent letter:ycurrent letter:tcurrent letter:ocurrent letter:ncurrent variable Value:9curren T variable value:8current variable value:7current variable value:6current variable value:4current variable value: 3Current variable value:2current variable value:1current variable value:0good bye!