标签:-- 程序 font int lse pre else day out
#while else 当while循环被break打断,则不走else程序
count = 0
while count <= 5:
count += 1
print(‘loop‘,count)
else:
print(‘循环正常执行完毕‘)
print(‘-----out of while loop----‘)
loop 1
loop 2
loop 3
loop 4
loop 5
loop 6
循环正常执行完毕
-----out of while loop----
count = 0
while count <= 5:
count += 1
print(‘loop‘,count)
if count == 4 :break
else:
print(‘循环正常执行完毕‘)
print(‘-----out of while loop----‘)
loop 1
loop 2
loop 3
loop 4
-----out of while loop----
标签:-- 程序 font int lse pre else day out
原文地址:https://www.cnblogs.com/zhaohongyu6688/p/8962985.html