Python循环-break和continue

时间:2022-02-09 20:29:53

break用于完全结束一个循环,跳出循环体,执行循环后面的语句

# -*- coding:utf-8 -*-
__author__ = "MuT6 Sch01aR"

count = 0
while count <=10:
print('loop',count)
if count == 4:
break #结束整个循环
count +=1
print('End')

运行结果

Python循环-break和continue

continue用于终止本次循环,继续进行下一轮循环

Python循环-break和continue