28
流程控制
■ 條件執行
● if:… elif: … else: …
■ 迴圈
● for in: … else: …
■ break
■ continue
■ 常搭配 xrange() 使用
● while: … else: …
if (v is True) and (w is True):
# 當 v 與 w 為 True 時執行
elif x is not True:
# 當 x 不為 True 時執行
else:
# 當 v 與 w 不為 True 且 x 為 True
for e in c:
# 對 c 中的所有元素 e 進行作業
else:
# 迴圈結束後執行
while a != b:
# 對 a 與 b 的值仍相異時執行
else:
# 迴圈結束後執行