Invalid Syntax


#1

Under the comment “#This is the math that will be calculated,”
Python is telling me that calc_county is an invalid syntax and I can’t see the problem.
Any guidance would be greatly appreciated.

def main():
    intro()
    user_info()

#We being the program with an introduction for the user.

def intro():
    print("Welcome to our Total Tax calculator!")
    print("Let's begin by entering your total sales for the month.\n")

#Define all variables and constants.

def user_info():
    STATE_SALES_TAX = .04 #The variable are constants and the value are floats.
    COUNTY_SALES_TAX = .02 #The variable are constants and the value are floats.

#define variables
    total_monthly_sales = 0.0 #float
    calc_county = 0.0 #float
    calc_state = 0.0 #float
    total_sales_tax = 0.0 #float

#We ask the user to enter their monthly total sales
    total_monthly_sales = float(input("Please enter your total sales for the month.\n")

#This is the math that will be calculated
    calc_county = total_monthly_sales * COUNTY_SALES_TAX
    calc_state = total_monthly_sales * STATE_SALES_TAX
    total_sales_tax = calc_county + calc_state

#Tell the user their county taxes, state taxes, and total taxes.
    print("Your county taxes are: " + str(calc_county ))
    print("Your state taxes are: " + str(calc_state ))
    print("Your total taxes are: " + str(total_state_tax))

#Thank the user for using our program.
    print("Thank you for using our tax calculator program!")
    print("Goodbye!")

main()

#2

also always pay attention to the line above the error message line:

total_monthly_sales = float(input("Please enter your total sales for the month.\n")

notice anything that looks off?


#3

Unfortunately I do not see the problem.


#4

look at the parentheses.


#5

-smacks forehead-. Thank you.
I was so focused on syntax error on calc_county I didn’t even consider looking at punctuation.
I appreciate it very much.


#6

the missing parenthesis is what caused the syntax error, using parenthesis you can put the code over multiple lines, which is why the error came later.


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.