Python 为什么for循环给我一个解析错误?
下面是我用于Python挑战的一段代码Python 为什么for循环给我一个解析错误?,python,for-loop,Python,For Loop,下面是我用于Python挑战的一段代码 for letter in range(10,switches - 10): if switchpoints[letter] == switchpoints[letter - 1] + 3 and switchpoints[letter] == switchpoints[letter + 1] - 1 and switchpoints[letter] == switchpoints[letter + 2] - 4 and switc
for letter in range(10,switches - 10):
if switchpoints[letter] == switchpoints[letter - 1] + 3 and switchpoints[letter] == switchpoints[letter + 1] - 1 and switchpoints[letter] == switchpoints[letter + 2] - 4 and switchpoints[letter] % 2 == 1:
print(str(letter) + "-" + str(switchpoints[letter])
for the_point in range( -3 , 4 ):
print(str(switchpoints[letter + the_point]))
第一个for循环工作正常,if语句也一样,但是第二个for循环给了我一个错误。当我在网站上测试它时,它告诉我我有一个解析错误,但对我没有帮助。为什么这会给我一个错误?您缺少一个)
:
您可能还需要考虑一下您的逻辑。你确定你的支票是对的吗
print(str(letter) + "-" + str(switchpoints[letter]))
#--------------------------------------------------^