Lesson 1#12 break 和 continue

break

用于跳出本层循环,循环体结束

continue

用于跳出本次循环,循环体未结束

举例:

 break 举例

count = 0
while count < 10:
    count += 1
    if count == 5 :
        break    #用于跳出本层循环
    else:
        print("count number:", count)
View Code

continue 举例
count = 0
while count < 10:
    count += 1
    if count == 5 :
        continue    #用于跳出本次循环
    else:
        print("count number:", count)
View Code

 

posted @ 2018-03-09 15:16  WudTime  阅读(157)  评论(0编辑  收藏  举报