Python Continue statement Usage instance

Source: Internet
Author: User
Python jumps out of the loop using the Continue statement, and break jumps out of the loop. The continue statement is used to tell Python to skip the remaining statements of the current loop, and then proceed to the next round of loops. The continue statement is used in the while and for loops.

One, the Python language continue statement syntax format is as follows:

The code is as follows:

Continue

Second, the logical flowchart:

Iii. Examples of Use:

The code is as follows:

#!/usr/bin/python

For letter in ' Python ': # First Example
If letter = = ' h ':
Continue
print ' Current letter: ', letter

var = ten # Second Example
While var > 0:
var = var-1
if var = = 5:
Continue
print ' current variable value: ', var
Print "Good bye!"


The result of the above instance execution:

The 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.