我是Python 3的新手,我已经开始学习If语句,但是当我运行代码时,它说“elif”无法识别?
intE = 20
if intE < 20:
print("Value is less than 20")
elif intE > 20:
print("Value is more than 20")
else:
print("Value is 20")
答案 0 :(得分:4)
问题是你的缩进
intE = 20
if intE < 20:
print("Value is less than 20")
elif intE > 20:
print("Value is more than 20")
else:
print("Value is 20")
答案 1 :(得分:1)
在python中,所有关于缩进的内容:) if
,elif
和else
必须位于同一列中:
intE = 20
if intE < 20:
print("Value is less than 20")
elif intE > 20:
print("Value is more than 20")
else:
print("Value is 20")
答案 2 :(得分:0)
实际上它应该是:
intE = 20
if intE < 20:
print("Value is less than 20")
elif intE > 20:
print("Value is more than 20")
else:
print("Value is 20")