Re: Error in while loop code for packing items

2016-08-18 Thread MRAB
On 2016-08-18 14:10, GP wrote: On Thursday, August 18, 2016 at 5:59:43 PM UTC+5:30, Peter Otten wrote: GP wrote: [snip] However, when you really want to remove all items you instead assign a new empty list for item in items: print(item) items = [] Thanks Peter for the information. It

Re: Error in while loop code for packing items

2016-08-18 Thread GP
On Thursday, August 18, 2016 at 5:59:43 PM UTC+5:30, Peter Otten wrote: > GP wrote: > > The error and your second snippet aren't compatible, so I assume the > exception is raised by > > > for k in range(0,len(shelf)): > > q1=ListDictItem[k] > > q2 = ListDictItem.pop(k) #deletes the i

Re: Error in while loop code for packing items

2016-08-18 Thread Peter Otten
GP wrote: The error and your second snippet aren't compatible, so I assume the exception is raised by > for k in range(0,len(shelf)): > q1=ListDictItem[k] > q2 = ListDictItem.pop(k) #deletes the items that are packed. > Error message:Traceback (most recent call last): > File "C:\P

Error in while loop code for packing items

2016-08-18 Thread GP
I have a list dictionary of items: ListDictItem = [ {'Item No': 1,'Weight':610,'Quantity':2},{'Item No': 2,'Weight':610,'Quantity':2},{'Item No': 3,'Weight':500,'Quantity':2},{'Item No': 4,'Weight':484,'Quantity':2},{'Item No': 5,'Weight':470,'Quantity':2},{'Item No': 6,'Weight':440,'Quantity