The usage of continue in Python3

Source: Internet
Author: User

Continue: Ends the current iteration and jumps to the beginning of the next iteration

1i =02num = [1,2,3,4,5]3  whileI < 3:4     Print(i)5 6      forJinchNum:7         Print("For loop%d times"%j)8         ifJ < 2:9             Print("if loop,%d times"%j)Ten         elifj = = 4: One              Break  #jump out of the for loop into the while loop, visible break jumps out of the two-layer loop A         Else: -             Continue #Skip to line 6th for Loop -i + = 1

Output:

0
For Loop 1th time
If Loop, 1th time
For Loop 2nd time
For Loop 3rd time
For Loop 4th time
1
For Loop 1th time
If Loop, 1th time
For Loop 2nd time
For Loop 3rd time
For Loop 4th time
2
For Loop 1th time
If Loop, 1th time
For Loop 2nd time
For Loop 3rd time
For Loop 4th time

The usage of continue in Python3

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.