while-else 1、break立即打斷迴圈並且不再執行else 2、while迴圈後會執行else ...
while-else
1、break立即打斷迴圈並且不再執行else
count = 0 while count <= 5: count += 1 if count == 3: break print("loop",count) else: print("迴圈執行完了") print("end")
2、while迴圈後會執行else
count = 0 while count <= 5: count += 1 if count == 3: pass print("loop",count) else: print("迴圈執行完了") print("end")