What else is there in Python?
[size=10.5pt]We all use the else keyword in Python,usually accompanying if statement:
CODE:
if x > 0:print 'positive'
elif x < 0:
print 'negative'
else:
print 'zero' [size=10.5pt]but Python has a few other uses to the else keyword that mostpeople are unfamiliar with.
for .. else
I bet you didn’t know that you can put an else clause after a for loop! What does it do? When the items you iterator over are exhausted, the else clause is executed. When aren’t the items exhausted? When you use a break statement.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/301743/viewspace-736618/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Python if..elsePython
- python的for..elsePython
- what is the Mixin method in Python?Python
- python 中的 for-else 和 while-else 語句PythonWhile
- python中for……else……的使用Python
- 善用python的else子句Python
- python中的while...elsePythonWhile
- Python if else條件語句Python
- Python 無處不在的 elsePython
- python學習:for else語句Python
- What---Python演算法Python演算法
- JS - if else and else if statementJS
- Python 基礎 - if else流程判斷Python
- Python中if else語句出錯Python
- Python if else條件語句詳解Python
- GoldenGate - What is supported and what is not ....Go
- Python 中的for,if-else和while語句PythonWhile
- Python中迴圈語句中的else用法Python
- What is it?
- python 利用 for ... else 跳出雙層巢狀迴圈Python巢狀
- Python的if else 巢狀 和forin while 迴圈Python巢狀While
- What is WebpackWeb
- What is Babel?Babel
- What is MySQL?MySql
- What is Gravity
- what is life?
- Python異常處理 try、except和else的使用Python
- c# 判斷多分支學習if else if elseC#
- 你所不知道的python 迴圈中的elsePython
- What is an SQL relation?SQL
- What time is it on Mars?
- what the fuck java is?Java
- What is tradebit?
- What is functor in Haskell ?Haskell
- What is Scalability?
- what is ORACLE ACEOracle
- what is sql?(轉)SQL
- In Oracle,What Is a Service?Oracle