I have the code below and I get everything except the bonus in the output. I tried it a few different ways and the bonus never comes out right after the staff and sales.

#get user input for sales bonuses and make calculations
#print headers
print" Sales Tracking Program"
print

#sales person values
saleval = []
stafflist = []
bonuslist = []
bonuslist = saleval
bonus = 0

#get the name of the salesperson
#for guy in stafflist:

#get the sales for calculations change range to add a person
for i in range(0,3,1):
    staff = str(raw_input('Enter staff member Name: '))
    sales = int(raw_input('How much is the sale? '))
    stafflist.append (staff)
    saleval.append(sales)    
    i += 1

for sales in bonuslist:
    if sales < 0:        
        print"The negative number ended the user input."         

    if sales > 221:
                    bonus += 200 + 25


    if 176 < sales < 220:                   
                    bonus += 200 + 20 

    if 101 < sales < 175:       
            bonus += 200 + 15
            print bonus

    elif 0 < sales < 100:        
            bonus += 200 + 10

print'Monthly Sales List $',saleval
print

i = 0
for e in stafflist:
    print "Sales Person",e, " Sales ",saleval[i],bonuslist[b]
    i += 1

print 'Total monthly sales are $', sum(saleval)

Recommended Answers

All 4 Replies

bonuslist will always be the same as the saleval list
bonuslist = saleval
You add the bonus to the field named "bonus" but try to print "bonuslist" which you do not change. See if using a lists of lists, that is one sub_list for each [staff, sales, bonus] helps. Generally you would use a dictionary for each sales person pointing to a list containing sales & bonus, but I am assuming that you have not covered dictionaries yet. Also, do not use "i", "l", "or "O" as single digit variable names as they look too much like numbers.

sales_list = []
for i in range(0,3,1):
    staff = str(raw_input('Enter staff member Name: '))
    sales = int(raw_input('How much is the sale? '))
    if sales >= 0:
        bonus = 0
        ## if sales < > statements here
        sales_list.append ([staff, sales, bonus])

    ## --- this "i" is different from the "i" used in the for loop and does nothing
    ## i += 1

##--- print each sub-list
for ctr, this_entry in enumerate(sales_list):
    print ctr, this_entry

## print the second sales person
this_entry = sales_list[1]
print "\nname =" this_entry[0]
print "sales =", this_entry[1]
print "bonus =", this_entry[2]

This entry at line 19 gives a snytax error that I dont really know what to do with.

OK never mind I see the error I need a comma before each this entry in the print statements. I also need to look up enumerate to see how it works I have not used that before. I do appreciate the help!!!!!!!!!

enumerate is the same as

ctr = 0
for this_entry in sales_list:
    print ctr, this_entry
    ctr += 1
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.