Python 流程控制:for
for 循环用于对一个序列进行遍历,用法如下:
In [4]: for i in 'abcd': ...: print(i) ...: a b c d
In [13]: for i in range(1, 10): # else 语句会在循环正常执行完的情况下执行,如果遇到break则不执行 ....: if i%5 == 0: ....: break ....: print(i) ....: else: ....: print("Hello") ....: 1 2 3 4