if语句的语法规则:
1、if 条件:
代码
如果条件成立就执行代码
如果不成立,就不执行
如:
i = int(input("please enter how much money you have left in you pocket:")) if i > 25: print("buy a box of boneless chicken feet")
2、if 条件:
代码1
else:
代码2
如果条件成立,执行代码1,否则,执行代码2
如:
i = int(input("please enter how much money you have left in you pocket:")) if i > 25: print("buy a box of boneless chicken feet") else: print("money making")
3、if语句可以互相嵌套
if 条件:
if 条件:
代码1
else:
代码2
else:
代码3
如:
i = int(input("please enter how much money