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

2024-10-03 02:32:01 发布

您现在位置:Python中文网/ 问答频道 /正文

下面是我在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循环给了我一个错误。当我在网站http://interactivepython.org/runestone/static/thinkcspy/index.html上测试它时,它告诉我有一个解析错误,但对我没有帮助。为什么这会给我一个错误?你知道吗


Tags: andthe代码inforif错误range