for … else …

以高雄發大財為例

PHIL
十百千實驗室

--

請按下方▷,看看和你想得一不一樣

IG: 1001000.io

你 484 以為只會印五行,那你該讀文件了

https://docs.python.org/3/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops

(Yes, this is the correct code. Look closely: the else clause belongs to the for loop, not the if statement.)

When used with a loop, the else clause has more in common with the else clause of a try statement than it does with that of if statements: a try statement’s else clause runs when no exception occurs, and a loop’s else clause runs when no break occurs.

一圖以蔽之

--

--