This article brings you a detailed introduction to the if statement in python. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
input() gets the string. bool: Only empty values are False, any characters are True
elif
If it is a multi-condition branch, different conditions will execute differently, use The format of elif
is as follows:
if 条件1 执行代码1 elif 条件2 执行代码2 elif 条件3 执行代码3 ....... else 以上条件都不满足执行代码
can be regarded as a code block from if to elif to else and the indented code below it.
if nested
if 条件1: if 条件2: 执行 else 不满足条件2: 执行 else 不满足条件1: 执行
pycharm Tips: Select multiple lines and press Tab to add indentation in front of each line, and then press Shift Tab to cancel the indentation
The above is the detailed content of Detailed introduction to if statement in python. For more information, please follow other related articles on the PHP Chinese website!