- Hands-On Penetration Testing with Python
- Furqan Khan
- 123字
- 2021-07-02 14:13:53
The if...elif condition
The if...elif ladder, popularly known as if...else if in other programming languages such as C, C ++, and Java, has the same function in Python. An if condition let's us specify a condition alongside the else part of the code. Only if the condition is true is the section proceeding the conditional statement executed:
a=44
b=66
if a > b:
print("a is Greater")
elif b > a:
print("B is either Greater or Equal")
else:
print("A and B are equal")
print("End")
It must be noted that the third else in the preceding code snippet is optional. Even if we don't specify it, the code works just fine:

Let's create a file named if_el_if.py, and see how this can be used:

推薦閱讀
- Data Visualization with D3 4.x Cookbook(Second Edition)
- TypeScript Essentials
- Redis Applied Design Patterns
- Java面向對象軟件開發
- Learning Spring 5.0
- Cross-platform Desktop Application Development:Electron,Node,NW.js,and React
- x86匯編語言:從實模式到保護模式(第2版)
- PHP+MySQL網站開發項目式教程
- 程序員修煉之道:通向務實的最高境界(第2版)
- Python時間序列預測
- 用戶體驗增長:數字化·智能化·綠色化
- Getting Started with Gulp
- Corona SDK Mobile Game Development:Beginner's Guide(Second Edition)
- Android應用開發實戰(第2版)
- AMP:Building Accelerated Mobile Pages