Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My paths and information are correct. Im trying to just get a series of stars ( * * * * * ) to appear infront

My paths and information are correct. Im trying to just get a series of stars (*****) to appear infront of the 4 digits of the social. It should look like *****6789.
But when I try my code breaks saying
Traceback (most recent call last):
File "C:/Python/Python312/test.py", line 113, in
ShowData() # Display employee information
File "C:/Python/Python312/test.py", line 104, in ShowData
obj.get_Lname(),+"*****"+ obj.get_social()[5:], obj.get_hrs_worked(), obj.get_rate(), obj.get_gross()))
TypeError: bad operand type for unary +: 'str'
As far as I can tell this should work its worked through the rest of my code but doesnt here. Here is the section it came from. **Note: The blank space in the between the first set of plus signs has to be there to match the code format of what this is supposed to be. It does not throw an error. I only got an error after adding in the series of stars but I also need those to match the format but they are whats breaking the code. Why would it take one over the other and how would I alleviate this?
def ShowData():
#displays information
try:
with open("C:\\employee.dat", "rb") as file:
print("{: <20}{: <15}{: <10}{: <10}{: <10}".format("Employee Name", "ID", "Hours Worked", "Pay Rate", "Gross Pay"))
print("------------------------------------------------------------------------")
while True:
try:
obj = pickle.load(file)
print("{: <20}{: <15}{: <10}{: <10}{: <10}".format(obj.get_Fname()+""+
obj.get_Lname(),+"*****"+
obj.get_social()[5:], obj.get_hrs_worked(), obj.get_rate(), obj.get_gross()))
except EOFError:
break
except FileNotFoundError:
print("The file could not be found.")
if __name__=="__main__":
# runs the following functions
EmployeeInfo() # Input employee information
ShowData() # Display employee information

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Chemical Engineering questions