Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么for循环给我一个解析错误?_Python_For Loop - Fatal编程技术网

Python 为什么for循环给我一个解析错误?

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

下面是我用于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     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]))
#--------------------------------------------------^