- 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:

推薦閱讀
- Dynamics 365 for Finance and Operations Development Cookbook(Fourth Edition)
- Java入門經(jīng)典(第6版)
- Visual FoxPro程序設(shè)計教程(第3版)
- DevOps入門與實踐
- Java編程指南:基礎(chǔ)知識、類庫應(yīng)用及案例設(shè)計
- 匯編語言程序設(shè)計(第2版)
- Building a Recommendation Engine with Scala
- 小學(xué)生C++創(chuàng)意編程(視頻教學(xué)版)
- Python深度學(xué)習(xí):基于TensorFlow
- Azure Serverless Computing Cookbook
- Domain-Driven Design in PHP
- Building Slack Bots
- 算法秘籍
- 你真的會寫代碼嗎
- Mastering Bootstrap 4