Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Getting error: "TypeError: 'list' object is not callable" in code [closed]

$
0
0

I have a code written up that I believe is finished, except now when I try to run it, I'm getting the following error:

Traceback (most recent call last):  File "D:/python/salaries.py", line 29, in <module>    pay = totalManagerPay(salary)TypeError: 'list' object is not callable

I've already done some Googling but every "solution" I find doesn't seem to work in my particular case, so I figured I'd ask here myself.

My code is here:

now = datetime.now()dt_string = now.strftime("%m/%d/%Y %H:%M:%S")def totalManagerPay(salary):    return salarydef totalHourlyPay(hours, rate):    overtime = max(0, hours - 40)    return (hoursWorked - overtime) * hourlyPay + overtime * hourlyPay * 1.5def totalCommissionPay(sales):    return 350 + 0.057 * salesdef totalPieceWorkerPay(pieces):    bonus = 500 if pieces > 500 else 0    return pieces * 4.50 + bonustotalManagerPay, totalHourlyPay, totalCommissionPay, totalPieceWorkerPay = [], [], [], []while True:    payCode = int(input("Enter pay code (0 to quit): "))    if payCode == 0:        print("No employees at this time. Thank you.")        break    if payCode == 1:        print("MANAGER SELECTED")        salary = float(input("Enter gross weekly salary: "))        pay = totalManagerPay(salary)        totalManagerPay.append(pay)    elif payCode == 2:        print("HOURLY WORKER SELECTED")        hoursWorked = float(input("Enter number of hours worked: "))        hourlyPay = float(input("Enter hourly rate: "))        pay = totalHourlyPay(hoursWorked, hourlyPay)        totalHourlyPay.append(pay)        print("Hourly worker's pay is ${pay:.2f}\n")    elif payCode == 3:        print("COMMISSION WORKER SELECTED")        weeklySales = float(input("Enter weekly sales: "))        pay = totalCommissionPay(weeklySales)        totalCommissionPay.append(pay)        print("Commission worker's pay is ${pay:.2f}\n")    elif payCode == 4:        print("PIECE BY PIECE WORKER SELECTED")        piecesProduced = int(input("Enter number of pieces produced: "))        pay = totalPieceWorkerPay(piecesProduced)        totalPieceWorkerPay.append(pay)        print("Piece by Piece worker's pay is ${pay:.2f}\n")    else:        print("Error. Please enter a valid code.")if any([totalManagerPay, totalHourlyPay, totalCommissionPay, totalPieceWorkerPay]):    print("\n******************** ABCD Inc. ************************")    print("*********** Cumulative Salaries By Pay Code ***********")    print("Employee Pay Code      Number of Employees     Cumulative Salary")    print("-----------------------------------------------------------------------------")    totalSalary, totalEmployees = 0, 0    for payCode, payList in enumerate([totalManagerPay, totalHourlyPay, totalCommissionPay, totalPieceWorkerPay], start=1):        total = sum(payList)        totalSalary += total        totalEmployees += len(payList)        print(f"        {payCode:<25}{len(payList):<25}{total:.2f}")    print("------------------------------------------------------------------------------")    print(f"Totals                           {totalEmployees:<34}  {totalSalary:.2f}")    print("--------------------------------------------------------------------------------")    print("Date: " + dt_string)    print("************************************************************************")

I thought the error would be when I call the functions in the bottom if-statement, however, when I remove the parentheses, I still get an error.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>