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
4python

Process finished with exit code 0ui



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
4debug

Process finished with exit code 0code

相關文章
相關標籤/搜索