【发布时间】:2014-07-19 10:22:52
【问题描述】:
所以我在第一节 GCSE 计算机科学课上得到了一本 Python 小册子。一项任务要求我使用 and,or and not 运算符来提高此代码的效率:
one=int(input("Please Enter Number 1:"))
two=int(input("Please Enter Number 2:"))
three=int(input("Please Enter Number 3:"))
if(one==two):
if(two==three):
print ("SNAP!")
else:
print ("The Do not all match")
else:
print("They do not all match")
但是我对 aand 或 and not 运算符一无所知。我试图找到正确的语法来使用。
然后我尝试使用此代码:
one=int(input("Please Enter Number 1:"))
two=int(input("Please Enter Number 2:"))
three=int(input("Please Enter Number 3:"))
if one==two and two==three:
print ("SNAP!")
else:
print ("The Do not all match")
else:
print("They do not all match")
但收到错误消息“未缩进与任何外部缩进级别不匹配”
我现在有点卡住了,因为我不知道这应该是什么意思,我知道这可能是一个简单的解决方法,但如果有人能指出我正确的方向,我将不胜感激,谢谢!
【问题讨论】:
-
1) 将第四行的缩进减少一级。 2) 只使用一个
else子句。
标签: python syntax syntax-error