The difference between break and continue in Python

Source: Internet
Author: User

1.break End Loop

Count = 0while Count <:    print (' Hello,jay ', count) break    count = count+1

The result of this code is that it will only print once "Hello,jay". Since a break is encountered, the loop is ended, and the statements in the loop body are not executed.

  

2.continue jump out of this cycle, in the loop body, again cycle

Cases:

Count = 0while Count <:    print (' Hello,jay ', count)    continue    count = count+1

The effect of this code will be a dead loop, and it will always print "Hello,jay". Because count never equals 10, every time the code arrives, the continue will start executing again from the while loop.

  

PS: In order to intercept this code running results diagram, the code after the run did not actively end the run, the computer suddenly alarm, CPU temperature 81 ℃, special scare me a jump ┭┮﹏┭┮

 


The difference between break and continue in Python

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.