My program is supposed to output a list of users who input their sales name along with their sales amount and then print out a display. I am using a nested for loop to read through the list of salespeople along with their sales amounts. The problem is that my for loops keep printing out the salesperson along with the sales of other users...
This is the output:
Enter Sales Person: (Press ENTER to quit) reg
Enter the sales amount: 600
Enter Sales Person: (Press ENTER to quit) tee
Enter the sales amount: 300
Enter Sales Person: (Press ENTER to quit) mark
Enter the sales amount: 200
Enter Sales Person: (Press ENTER to quit)
=============== =============== =============
=============== =============== =============
Sales Person: 1.reg Sales: 600
Sales Person: 2.tee Sales: 600
Sales Person: 3.mark Sales: 600
Sales Person: 1.reg Sales: 300
Sales Person: 2.tee Sales: 300
Sales Person: 3.mark Sales: 300
Sales Person: 1.reg Sales: 200
Sales Person: 2.tee Sales: 200
Sales Person: 3.mark Sales: 200
Code:
for sale in range(len(salesAmounts)):
for name in range(len(newSalesPerson)):
label = str(1 + name) + '.'
print 'Sales Person: ', label + newSalesPerson[name] + ' Sales: ', salesAmounts[sale]
Enter Sales Person: (Press ENTER to quit) reg
Enter the sales amount: 600
Enter Sales Person: (Press ENTER to quit) tee
Enter the sales amount: 300
Enter Sales Person: (Press ENTER to quit) mark
Enter the sales amount: 200
Enter Sales Person: (Press ENTER to quit)
=============== =============== =============
=============== =============== =============
Sales Person: 1.reg Sales: 600
Sales Person: 2.tee Sales: 600
Sales Person: 3.mark Sales: 600
Sales Person: 1.reg Sales: 300
Sales Person: 2.tee Sales: 300
Sales Person: 3.mark Sales: 300
Sales Person: 1.reg Sales: 200
Sales Person: 2.tee Sales: 200
Sales Person: 3.mark Sales: 200
Comment