Python Forum
TypeError: '<=' not supported between instances of 'list' and 'int'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: '<=' not supported between instances of 'list' and 'int'
#1
#Print A Simple Payroll Report
name = ['Hai', 'Bell', 'Cindy', 'Danny', 'Eddy', 'Felicia', 'Gigi', 'Apple','Indie','Jacon','Kim','Lim']
hours = [10, 45, 60, 70, 20, 35, 80, 30, 65, 55, 15, 90]
rate = 9.5


n = len(name)

print('\n\t    Payroll Report\n')
print('No.\tEmployee Name\tHours\tSalary(RM)')

for i in range(n):
    if hours <= 40:
        wage = hours*rate
    elif  hours <= 60:
        wage = 380 + (hours + 40) * rate * 1.5
    else:
        665 + (hours + 60) * rate * 2.0
        

    print('%d\t%s\t%d\t%s' % (i+1, name[i], hours[i], wage))


Why is it not supported?
Or did I miss something?
Reply
#2
Line 13.
You cannot compare a sequence against an integer.
Same for the elif statement.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
I forgot to mention
I was thinking to make an Output like this:

No. Employee Name Hours Salary(RM)
1 XXX 10 75
2 CCC 45 356.25
3 Bell 65 675
Reply
#4
When I understand your code correctly, you want to compare the hours of one person with 40(60), so you need the hours at the position of i, so
if hours[i] <= 40:
        wage = hours*rate
Reply
#5
(May-01-2018, 11:19 AM)ThiefOfTime Wrote: When I understand your code correctly, you want to compare the hours of one person with 40(60), so you need the hours at the position of i, so
if hours[i] <= 40: wage = hours*rate

Yessss!
Thanks, sorry forgot to reply.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  please Help. TypeError: list indices must be integers, not str skamaaa01 1 4,387 Feb-04-2018, 12:33 PM
Last Post: Gribouillis
  List showing running total of instances Pie_Fun 11 9,560 Jan-20-2017, 11:29 PM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020