I am reading a text file inside Python that contains salaries and the raise they will receive as a percent. I am trying to multiply the initial salary by the percent and print the salary after the raise has been applied. I keep receiving an error message which is as follows: TypeError: can't multiply sequence by non-int of type 'str'
I realize it is a string and I try to evaluate the numbers but after I evaluate the numbers i receive another error message about an invalid syntax.
This is the code I have:
text_record = open("Employees.txt", "r") for line in text_record: name_DOB_salary = line.split() first_name = name_DOB_salary last_name = name_DOB_salary DOB = name_DOB_salary percent = 100 * name_DOB_salary initial_money = name_DOB_salary final_money = initial_money + (eval(initial_money + percent)) print 'Employee' , first_name , last_name , 'was born on' , DOB print 'At' , percent , '%, the salary will increase from $', initial_money , 'to' , final_money
The text file looks like this:
Jones Martin 12/14/1976 54254.87 .02
Cameron James 9/6/1982 44653.00 .025
Harris Ellen 10/10/1980 36876.50 .03
Forbes Malcolm 4/18/1945 8898765.55 .05
Cooper David 3/23/1979 39999.25 .025
If anyone can help point me in the right on how I can multiply these two figures that would be greatly appreciated. Many thanks!