for 循环

for 临时变量 in 序列:
    重复执行的代码1
    重复执行的代码2
    ……

my_str = 'hello python'  
for i in my_str:  
    print(i)

退出循环 break、continue

continue 退出当前一次循环;break 退出循环。

for else

for 临时变量 in 序列:
    重复执行的代码1
    重复执行的代码2
    ……
else:
    循环正常结束,执行代码

break、continue

如果 for 循环通过 break 终止的情况下,else 中的代码不执行。

如果 for 循环通过 continue 终止的情况下,else 中的代码继续执行。