Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Syntax Error
#1
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"))
Reply
#2
you dont need all those evals

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


Possibly Related Threads…
Thread Author Replies Views Last Post
Shocked School project -- need help with it it says syntax error XPGKNIGHT 6 3,318 Aug-11-2022, 08:43 PM
Last Post: deanhystad
  I'm getting a syntax error very early on in my code and I can't quite figure it out. liloliveoil 1 2,005 Oct-30-2020, 05:03 AM
Last Post: deanhystad
  Unspecified syntax error hhydration 1 2,008 Oct-25-2020, 10:45 AM
Last Post: ibreeden
  Annuity function for school - syntax error peterp 2 1,974 Oct-12-2020, 10:34 PM
Last Post: jefsummers
  Invalid syntax error, where? tucktuck9 2 3,424 May-03-2020, 09:40 AM
Last Post: pyzyx3qwerty
  Raise an exception for syntax error sbabu 8 3,157 Feb-10-2020, 01:57 AM
Last Post: sbabu
  syntax error: can't assign to operator liam 3 4,050 Jan-25-2020, 03:40 PM
Last Post: jefsummers
  Self taught , (creating a quiz) syntax error on my array DarkAlchemyXEX 9 4,261 Jan-10-2020, 02:30 AM
Last Post: ichabod801
  If Statements and Comparisons returns a syntax error DarkAlchemyXEX 2 2,438 Jan-02-2020, 01:25 PM
Last Post: DarkAlchemyXEX
  Syntax Error: Invalid Syntax in a while loop sydney 1 4,081 Oct-19-2019, 01:40 AM
Last Post: jefsummers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020