I keep getting a error for adding strings and integers together. how can I fix this? It is in the line hours.append(hWork + "\n")

hours=[]
hWork="1"
while True:
    employee=raw_input("\nPlease enter the employees' first and last name. ")
    hWork=int(raw_input("How many hours did they work this week? "))
    if hWork < 1 or hWork > 60:
        print "Employees' can't work less than 1 hour or more than 60 hours!"
        continue
    else:
        pRate=int(raw_input("What is their hourly rate? "))
        if pRate < 6 or pRate > 20:
            print "Employees' wages can't be lower than $6.00 or greater than $20.00!"
        else:
            hours.append(hWork + "\n")
            empDone = ""
            empDone = raw_input("Type DONE when finished with employees' information. ")
            if empDone == "DONE":

Recommended Answers

All 3 Replies

why you want to add new line to hours?

this is the error i am getting.

Traceback (most recent call last):
File "C:/Users/Office/Desktop/py.py", line 32, in <module>
hours.append(hWork + "\n")
TypeError: unsupported operand type(s) for +: 'int' and 'str'

'\n' is not number like error says. Also work times do not contain newlines.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.