Python Forum

Full Version: Syntax Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I am new to programming and am having trouble with a program I am creating. I am using an array to create a tax form with 13 lines. At line 7 and beyond I get a syntax error and I'm not sure why. Any suggestions would be helpful. Thanks

#Tax Form
print ("Welcome to the 1040EZ Tax Form Application")

#array
t = ["","","","","","","","","","","","",""]

#1
t [0] = eval(input ("Wages,salaries, and tips. This should be shown in box 1 of your Form(s) W-2. Attach your Form(s) W-2.: "))
print (format(t [0], ",.2f"))

#2
t [1] = eval(input ("Taxable inerest.: "))
print (format(t [1], ",.2f"))

#3
t [2] = eval(input ("Unemployment compensation and Alaska Permanent Fund dividends.: "))
print (format(t [2], ",.2f"))
x = int(t [0] + t [1] + t [2])

#4
eval
print ("Add lines 1, 2, and 3. This is your adjusted gross income. $" + str(x))

#5
y = 10150

print ("If no one can claim you (or your spouse if a joint return), enter $10,150 if single; $20,300 if married filing jointly. See back for explanation $" + str(y))

#6
taxinfo [4] = eval(input ("Subtract line 5 from line 4. If line 5 is larger than line 4, enter -0-. This is your taxable income.: $" + [str(x)- str(y)])

#7
taxinfo [6] = eval(input ("Federal income tax withheld from your W-2 and 1040"))
print (format(t [6], ",.2f"))

#8
taxinfo [6] = eval(input ("Earned income credit (EIC): "))
print (format(t [7], ",.2f"))
x1 = int(t [6] + t [7])

#9
print ("Add lines 7 and 8. These are your total payments and credits.: $" + str(x1))

#10
print ("Tax. Multiply Line 6 by 0.15.: $" + [t [6]*0.15])

#11
t [11] = eval(input ("Health care: individual responsibility: "))
print (format(t [10], ",.2f"))

#12
print ("Add lines 10 and 11. This is your total tax.: $" + [t [6]*0.15] + t [10]))

#13
print ("If line 9 is larger than line 12, subtract line 12 from line 9. If result is positive, it is your refund. If result is negative, it is the amount you owe.: $" + [taxinfo [12] - taxinfo [9]]))
print (format(t [8] - t [8], ",.2f"))
you dont need all those evals

>>> t = float(input('num: '))
num: 3.1234567654
>>> t
3.1234567654
>>> '{:.2f}'.format(t)
'3.12'