循环控制语句
1.break,跳出循环 2.continue,跳过本次循环
while
代码语言:javascript复制i = 0
while 1 >= 100:
if i >= 10:
print("while循环结束")
result = False
else:
i = 1
print(f"while循环 - {i}")
for
代码语言:javascript复制for i in range(1,100):
if i <= 10:
if i % 2 == 0:
print(f"for循环 - {i}")
else:
print(f"for循环 - {i} - 非偶数,已跳过~")
continue
else:
print("跳出循环")
break