The "Python Basics" process controls-break and continue use and while. else's use

Source: Internet
Author: User
‘‘‘break 用于结束一个完整的循环,跳出循环体执行循环后面的语句continue 用于跳出本次循环,但继续下一个循环‘‘‘‘‘‘continue的用法打印1-10的数字,3除外‘‘‘# count = 1# while count <= 10:# if count == 3:# count+=1 ##如果不添加count+=1当打印到3,直接跳出本次循环这个时候count还是3,就无法进行下次循环# continue# print(count)# count+=1‘‘‘break 的用法打印1-10的数字‘‘‘# count = 1# while True:# if count > 10:# break ##当循环的结果>10时,break直接结束了这个while循环# print(count)# count+=1

The previous article is about the basic use of while, and here is the collocation of while and else

‘‘‘while 条件判断:    满足条件执行的代码块else:    最后执行的代码块else 当while循环正常执行完,中间没有被break终止的话,就会执行else后面的代码块‘‘‘count = 1while count < 10:    print(count)    count+=1else:    print("老大程序执行完了,请验收")

The "Python Basics" process controls-break and continue use and while. else's use

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.