2013-10-02 3 views
-1

나는 (제목에 명시된) 내가 쓰고 있어요 코드의 일부에 문제가있어주는 ELIF 문. 모든 엘프는 10 번째 줄에 있습니다 (예 : elif inc < = e 및 inc> d :). IDLE에서 오류가있는 것으로 강조 표시되어 있습니다. 여기 코드는 다음과 같습니다파이썬 - 유효하지 않은 구문 오류

def calc(a,b,c,d,e,f): 
    if inc <= a and inc >= 0: 
     tax = 0.10 * income 
    elif inc <= b and inc > a: 
     tax = (0.10 * a) + (0.15 * (income - a)) 
    elif inc <= c and inc > b: 
     tax = (0.10 * a) + (0.15 * b) + (0.25 * (income - b)) 
    elif inc <= d and inc > c: 
     tax = (0.10 * a) + (0.15 * b) + (0.25 * c) + (0.28 * (income - c)           
    elif inc <= e and inc > d: 
     tax = (0.10 * a) + (0.15 * b) + (0.25 * c) + (0.28 * d) + (0.33 * \ 
      (income - d)) 
    elif inc <= f and inc > e: 
     tax = (0.10 * a) + (0.15 * b) + (0.25 * c) + (0.28 * d) + (0.33 * \ 
      e) + (0.35 * (income - e)) 
    elif inc > f: 
     tax = (0.10 * a) + (0.15 * b) + (0.25 * c) + (0.28 * d) + (0.33 * \ 
      e) + (0.35 * f) + (0.396 * (income - f) 
    tax_str = str(tax) 
+4

괄호를 계산하십시오. –

답변

2

이 줄 : 당신은 마지막에 )를 추가하는 것을 잊었다

tax = (0.10 * a) + (0.15 * b) + (0.25 * c) + (0.28 * (income - c) 

.

파이썬은 이전 라인의 연속, 따라서 구문 에러로 다음 줄을 해석합니다.

관련 문제