Lesson 1#12 break 和 continue
break
用于跳出本层循环,循环体结束
continue
用于跳出本次循环,循环体未结束
举例:
break 举例
count = 0 while count < 10: count += 1 if count == 5 : break #用于跳出本层循环 else: print("count number:", count)
continue 举例
count = 0 while count < 10: count += 1 if count == 5 : continue #用于跳出本次循环 else: print("count number:", count)