for break与for continue

#!/usr/bin/evn python
 i in range(10):
if i<5:
print(i)
else:
break
这段代码执行5次,输出如下

Connected to pydev debugger (build 171.4249.47)
0
1
2
3
4

Process finished with exit code 0



for i in range(10):
if i<5:
print(i)
else:
continue
这个代码执行了10次才会结束,但是打印输出直到4

Connected to pydev debugger (build 171.4249.47)
0
1
2
3
4

Process finished with exit code 0

猜你喜欢

转载自www.cnblogs.com/monte-g/p/12523880.html
今日推荐