0

tax calculator

def computeTax(maritalStatus,userIncome):
  if maritalStatus == "Single":
    print("User is single")
    if userIncome <= 9075:
      tax = (.10) * (userIncome)
    elif userIncome <= 36900:
      tax = 907.50 + ((.15) * (userIncome - 9075))
    elif userIncome <= 89350:
      tax = 5081.25 + ((.25) * (userIncome - 36900))
    elif userIncome <= 186350:
      tax = 18193.75 + ((.28) * (userIncome - 89350))
    elif userIncome <= 405100:
      tax = 45353.75 + ((.33) * (userIncome - 186350))
    elif userIncome <= 406750:
      tax = 117541.25 + ((.35) * (userIncome - (405100)
    else:                                            # getting syntax error here
      tax = 118118.75 + ((.396) * (userIncome - (406750))
    return tax
  else:
    return "placeholder"

def main():
  maritalStatusMain = input("Please enter your marital status (Single or Married)")
  userIncomeMain = float(input("Please enter your annual income"))
  finalTax = computeTax(maritalStatusMain,userIncomeMain)
  print(finalTax)
main()

When I remove or add statements the syntax error seems to jump around.

1
  • Do you mean that if you remove one of the elif statements, the syntax error is no longer in front of the first else statement? Commented Sep 28, 2016 at 18:49

1 Answer 1

1

A quick glance at the lines around it, shows a missing parenthesis

...
  tax = 45353.75 + ((.33) * (userIncome - 186350))    # <- two ending parens
elif userIncome <= 406750:
  tax = 117541.25 + ((.35) * (userIncome - (405100)   # <- one ending paren, plus extra paren around 405100
else:
...

That's probably all it is, unless the copy+paste into the question failed

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.