我的if语句有问题,我不明白为什么。这是:
if (first == 1 and second > -1 and third < 1 and (sign(phi[i]) == sign(phi[i-1]) or sign(phi[i]) == sign(phi[i-2])):
foo()
它一直告诉我"invalid syntax"
。
你能发现无效的语法吗?
答案 0 :(得分:3)
你最后错过了一个括号:
if (first == 1 and second > -1 and third < 1 and (sign(phi[i]) == sign(phi[i-1]) or sign(phi[i]) == sign(phi[i-2]))):
^