Python中if else语句出错
Python中用if……else语句编写代码,结果出现错误:
源码为:
number = 2 if number == 2: print("you are fool") else: print("you are beautiful")
错误提示为:
仔细看了一下,结果是else的缩进发生了错误。
修正后的代码为:
number = 2 if number == 2: print("you are fool") else: print("you are beautiful")
运行结果为:
来源:PY学习网:原文地址:https://www.py.cn/article.html