Python “if语句”的语法无效

Python “if语句”的语法无效,python,syntax,Python,Syntax,我对我的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() 它总是告诉我无效的语法。 你能找出无效的语法吗?你在结尾处漏掉了一个括号: if (first == 1 and second > -1 and third < 1 and (si

我对我的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()
它总是告诉我无效的语法。
你能找出无效的语法吗?

你在结尾处漏掉了一个括号:

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]))):
                                                                                                                   ^

首先,你的缩进是错误的。第二,你试过什么?你在结尾缺少一个括号,或者在开头有一个括号太多了。投票以打字错误结束。投票以打字错误/norepro结束