2016-07-07 135 views
-9

我的if語句存在問題,我不明白爲什麼。它是:我的「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"。 你能發現無效的語法嗎?

+1

壓痕。 。 。? –

+1

您的縮進對於初學者來說是錯誤的。其次,你有什麼嘗試? – Jeremy

+1

您錯過了最後的括號,或者在開始處有太多的括號。投票結束爲錯字。 – molbdnilo

回答

2

你已經錯過了在最後一個括號:

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