This is my first function in python and i need to get item quantity and price loops into the function Processorderitems. I took out the items loop because I was not doing anything with it. I need to return the subtotal and I have a 3% discount for quantities over 10. I am not sure how to loop the information into and out of the function. Do I send the list or can you send each index? I have tried both ways so far and get errors. Here is what I have now.
print "This program calculates a total after the user enters: \n the Item, Quantity and Price" #define process function def Processorderitem(quantitylist,pricelist): #discount variable so it can be changed discount = .03 subtotal = 0 for i in range(len(quantitylist)): for j in range(len(pricelist)): subtotal[i] = quantitylist[i] * pricelist[j] while quantity >= 10: subtotal *= discount subtotal -= discount return subtotal #create lists for data itemlist =  quantitylist =  pricelist =  totlist =  quantity = 0 price = 0 total = 0 discount = .03 #get user input for i in range(0,2,1): item = str(raw_input('Enter an item: ')) quantity = int(raw_input('How many of these do you want? ')) price = int(raw_input('Enter the price: ')) itemlist.append(item) quantitylist.append(quantity) pricelist.append(price) print itemlist,quantity,price #loop over the lists # for item in enumerate(itemlist): for quantity in enumerate(quantitylist): for price in enumerate(pricelist): #call processorder function total = Processorderitem(quantitylist,pricelist) #get the total for i in (len(totlist)): total = Processorderitem(quantitylist,pricelist) print 'Item Name' + ' ' +'Quantity'+ ' ' +'Price' print item[i],quantity[i],total[i]
Edited by mike_2000_17: Fixed formatting