I keep receiving the error message:
AttributeError: 'str' object has no attribute 'append'
in relation to line 18 (last line below). And I can't see what I'm doing wrong. I thought the code converts all items in the 'employees' list into lists themselves. So it should not be returning a string error to append to one of these items.
This is my first programme not guided by a crash course book, so apologies if the answer is blindingly obvious
employees=[]
peeps=()
hours=()
total_hours=[]
tip=()
tips=int(input("What was the total tips?: "))
print("Enter employees' names followed by enter. Press x to stop")
while peeps != 'x': #input employee names
peeps=raw_input("Name: ")
employees.append(peeps)
def extractEmployees(employees): #covert employees to list of lists
return [[x] for x in [employees]]
extractEmployees(employees) #run conversion
for x in employees: #input hours worked by each employee
print("Enter hours for ", x, "individual daily hours followed by enter, or sum of hours worked. Press x when done")
while hours != 'x': #add hours to employee's list
hours=int(input())
x.append(hours)
extractEmployeesreturns. That function doesn't change the original list; it creates a new one based on the old list, and returns the new list.