循环中使用continue语句


1、continue语句用于结束本次循环

2、continue语句用于while循环或for循环

3、for循环中使用continue

for x in [1, 2, 3, 4, 5, 6]:
    if x == 4:
        continue
    print(x)

4、while循环中使用continue

a = 0
while a < 6:
    a += 1
    if a == 4:
        continue
    print(a)

results matching ""

    No results matching ""