Python continue statement usage example

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.