conditional statement in python

In python, the if statement is used to judge conditions and control the operation of the program. The syntax structure is as follows:

if 判断条件:
    执行语句……
else:
    执行语句……

When there are multiple judgment conditions, use the following syntax structure:

if 判断条件1:
    执行语句1……
elif 判断条件2:
    执行语句2……
elif 判断条件3:
    执行语句3……
else:
    执行语句4……

Example:

#!/usr/bin/env python
# -*- coding:utf-8 -*-


if __name__ == '__main__':
    a = 10
    if a == 10:
        print("yes")
    else:
        print("no")

output:

yes

Guess you like

Origin blog.csdn.net/kevinjin2011/article/details/129443870