Python Forum
Can't figure out syntax error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't figure out syntax error
#1
Hello! I'm new to this forum and decided to join for homework help. I have an assignment due tonight where I need to calculate a worker's total earnings before they retire at age 65. There is a syntax error in line 3 (startingSalary . . .) but I'm not sure what it is or how to fix it. Any help is appreciated.


name = input('Enter your name:')    #obtain name
currentAge = int(input('Enter your age:')  #obtain age
initialSalary = float(input('Enter your starting salary:')) #obtain starting salary
annualRaise = 0.05 #salary increases 5% annually
remainingWorkYears = 65 - age #years left to work
for age in range (age, 65):
   salary = (initialSalary * annualRaise) + startingSalary
   age +=1
print(name, 'will earn about $' , format(salary, ',.2f', sep=''))
A sample output should look like this
Output:
Enter name: Helen Enter age: 25 Enter starting salary: 20000 Helen will earn about $2,415,995.
Reply
#2
You are missing a closing parenthesis at the end of line two.

In the future, please use python tags for posting your code. Check out the BBCode link in my signature for how to use them.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
When you have a syntax error check the previous few lines too. If the pointed one is ok
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#4
Thank you ichabod and wavic for your help! I'll be sure to add tags in the future too.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Shocked School project -- need help with it it says syntax error XPGKNIGHT 6 3,256 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 1,968 Oct-30-2020, 05:03 AM
Last Post: deanhystad
  Unspecified syntax error hhydration 1 1,963 Oct-25-2020, 10:45 AM
Last Post: ibreeden
  Annuity function for school - syntax error peterp 2 1,928 Oct-12-2020, 10:34 PM
Last Post: jefsummers
  Invalid syntax error, where? tucktuck9 2 3,378 May-03-2020, 09:40 AM
Last Post: pyzyx3qwerty
  Raise an exception for syntax error sbabu 8 3,068 Feb-10-2020, 01:57 AM
Last Post: sbabu
  syntax error: can't assign to operator liam 3 3,994 Jan-25-2020, 03:40 PM
Last Post: jefsummers
  Self taught , (creating a quiz) syntax error on my array DarkAlchemyXEX 9 4,149 Jan-10-2020, 02:30 AM
Last Post: ichabod801
  If Statements and Comparisons returns a syntax error DarkAlchemyXEX 2 2,385 Jan-02-2020, 01:25 PM
Last Post: DarkAlchemyXEX
  Syntax Error: Invalid Syntax in a while loop sydney 1 4,027 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